Class: Intervention::Recorder::Cast

Inherits:
Object
  • Object
show all
Defined in:
app/models/intervention/recorder/cast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorder, type, name, object = nil, options = {}) ⇒ Cast

Returns a new instance of Cast.


6
7
8
9
10
11
12
13
# File 'app/models/intervention/recorder/cast.rb', line 6

def initialize(recorder, type, name, object = nil, options = {})
  @recorder = recorder
  @name = name
  @type = type
  @object = object
  @variant = options.delete(:variant).is_a?(TrueClass)
  @options = {}
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object


4
5
6
# File 'app/models/intervention/recorder/cast.rb', line 4

def object
  @object
end

Instance Method Details

#save!Object


15
16
17
18
19
20
21
# File 'app/models/intervention/recorder/cast.rb', line 15

def save!
  if variant?
    @recorder.intervention.add_cast!(@options.merge(reference_name: @name, variant: @object))
  else
    @recorder.intervention.add_cast!(@options.merge(reference_name: @name, actor: @object))
  end
end

#variant?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'app/models/intervention/recorder/cast.rb', line 23

def variant?
  @variant
end