Class: BroadcastEvent::SubjectHelpers::Subject

Inherits:
Object
  • Object
show all
Defined in:
app/models/broadcast_event/subject_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, target) ⇒ Subject


5
6
7
8
# File 'app/models/broadcast_event/subject_helpers.rb', line 5

def initialize(name, target)
  @role_type = name.to_s
  @target = target
end

Instance Attribute Details

#role_typeObject (readonly)

Returns the value of attribute role_type


3
4
5
# File 'app/models/broadcast_event/subject_helpers.rb', line 3

def role_type
  @role_type
end

#targetObject (readonly)

Returns the value of attribute target


3
4
5
# File 'app/models/broadcast_event/subject_helpers.rb', line 3

def target
  @target
end

Instance Method Details

#as_json(*_args) ⇒ Object


14
15
16
# File 'app/models/broadcast_event/subject_helpers.rb', line 14

def as_json(*_args)
  json_fields.each_with_object({}) { |field, hash| hash[field] = send(field) }
end

#broadcastable?Boolean


18
19
20
# File 'app/models/broadcast_event/subject_helpers.rb', line 18

def broadcastable?
  @target.present?
end

#json_fieldsObject


10
11
12
# File 'app/models/broadcast_event/subject_helpers.rb', line 10

def json_fields
  [:friendly_name, :uuid, :subject_type, :role_type]
end