Class: BroadcastEvent::SubjectHelpers::Subject

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

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

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_typeObject (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

#targetObject (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

Returns:

  • (Boolean)

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

def broadcastable?
  @target.present?
end

#json_fieldsObject


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