Class: SimpleStateMachine::Decorator::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_state_machine/decorator/default.rb

Overview

Decorates @subject with methods to access the state machine

Direct Known Subclasses

ActiveRecord

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject) ⇒ Default

Returns a new instance of Default.



8
9
10
# File 'lib/simple_state_machine/decorator/default.rb', line 8

def initialize(subject)
  @subject = subject
end

Instance Attribute Details

#subject=(value) ⇒ Object (writeonly)

Sets the attribute subject

Parameters:

  • value

    the value to set the attribute subject to.



7
8
9
# File 'lib/simple_state_machine/decorator/default.rb', line 7

def subject=(value)
  @subject = value
end

Instance Method Details

#decorate(transition) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_state_machine/decorator/default.rb', line 12

def decorate transition
  define_state_machine_method
  define_state_getter_method
  define_state_setter_method

  define_state_helper_method(transition.from)
  define_state_helper_method(transition.to)
  define_event_method(transition.event_name)
  decorate_event_method(transition.event_name)
end