Class: StateMachina::EventsCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/state_machina/events_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ EventsCollection

Returns a new instance of EventsCollection.



5
6
7
# File 'lib/state_machina/events_collection.rb', line 5

def initialize(events)
  @events = events
end

Instance Method Details

#each(&block) ⇒ Object



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

def each(&block)
  if block_given?
    @events.each(&block)
  else
    to_enum(:each)
  end
end

#find_by_name(event_name) ⇒ Object



17
18
19
20
21
# File 'lib/state_machina/events_collection.rb', line 17

def find_by_name(event_name)
  find do |event|
    event.name == event_name
  end
end