Class: Hifsm::Event

Inherits:
Object
  • Object
show all
Includes:
Callbacks
Defined in:
lib/hifsm/event.rb

Constant Summary collapse

CALLBACKS =
[:before, :after, :guard].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

#set_callbacks, #trigger, #trigger?

Constructor Details

#initialize(name, to, callbacks_options) ⇒ Event

Returns a new instance of Event.



9
10
11
12
13
14
15
# File 'lib/hifsm/event.rb', line 9

def initialize(name, to, callbacks_options)
  @name = name
  @to = to
  CALLBACKS.each do |cb|
    set_callbacks cb, callbacks_options[cb]
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/hifsm/event.rb', line 7

def name
  @name
end

#toObject (readonly)

Returns the value of attribute to.



7
8
9
# File 'lib/hifsm/event.rb', line 7

def to
  @to
end

Instance Method Details

#guard?(target, *args) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/hifsm/event.rb', line 17

def guard?(target, *args)
  trigger?(:guard, target, *args)
end