Class: AASM::SupportingClasses::State

Inherits:
Object
  • Object
show all
Defined in:
lib/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ State

Returns a new instance of State.



6
7
8
# File 'lib/state.rb', line 6

def initialize(name, options={})
  @name, @options = name, options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/state.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/state.rb', line 4

def options
  @options
end

Instance Method Details

#entered(record) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/state.rb', line 15

def entered(record)
  afteractions = @options[:after]
  return unless afteractions
  Array(afteractions).each do |afteract|
    record.send(:run_transition_action, afteract)
  end
end

#entering(record) ⇒ Object



10
11
12
13
# File 'lib/state.rb', line 10

def entering(record)
  enteract = @options[:enter]
  record.send(:run_transition_action, enteract) if enteract
end

#exited(record) ⇒ Object



23
24
25
26
# File 'lib/state.rb', line 23

def exited(record)
  exitact  = @options[:exit]
  record.send(:run_transition_action, exitact) if exitact
end