Class: BroadcastEvent::SubjectHelpers::Subject
- Inherits:
-
Object
- Object
- BroadcastEvent::SubjectHelpers::Subject
- Defined in:
- app/models/broadcast_event/subject_helpers.rb
Instance Attribute Summary collapse
-
#role_type ⇒ Object
readonly
Returns the value of attribute role_type.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #as_json(*_args) ⇒ Object
- #broadcastable? ⇒ Boolean
-
#initialize(name, target) ⇒ Subject
constructor
A new instance of Subject.
- #json_fields ⇒ Object
Constructor Details
#initialize(name, target) ⇒ Subject
Returns a new instance of Subject.
6 7 8 9 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 6 def initialize(name, target) @role_type = name.to_s @target = target end |
Instance Attribute Details
#role_type ⇒ Object (readonly)
Returns the value of attribute role_type.
4 5 6 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 4 def role_type @role_type end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 4 def target @target end |
Instance Method Details
#as_json(*_args) ⇒ Object
15 16 17 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 15 def as_json(*_args) json_fields.index_with { |field| send(field) } end |
#broadcastable? ⇒ Boolean
19 20 21 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 19 def broadcastable? @target.present? end |
#json_fields ⇒ Object
11 12 13 |
# File 'app/models/broadcast_event/subject_helpers.rb', line 11 def json_fields %i[friendly_name uuid subject_type role_type] end |