Class: CequelStatefulEnum::Machine
- Inherits:
-
Object
- Object
- CequelStatefulEnum::Machine
- Defined in:
- lib/cequel_stateful_enum/machine.rb
Defined Under Namespace
Classes: Event
Instance Method Summary collapse
- #event(name, &block) ⇒ Object
-
#initialize(model, column, states, &block) ⇒ Machine
constructor
A new instance of Machine.
Constructor Details
#initialize(model, column, states, &block) ⇒ Machine
Returns a new instance of Machine.
11 12 13 14 |
# File 'lib/cequel_stateful_enum/machine.rb', line 11 def initialize(model, column, states, &block) @model, @column, @states, @event_names = model, column, states, [] instance_eval(&block) end |
Instance Method Details
#event(name, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/cequel_stateful_enum/machine.rb', line 16 def event(name, &block) raise DefinitionError, "event #{name} has already been defined" if @event_names.include? name Event.new @model, @column, @states, name, &block @event_names << name end |