Class: RabbitFeed::EventRouting::Event

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/rabbit_feed/event_routing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, block) ⇒ Event

Returns a new instance of Event.



10
11
12
13
14
15
# File 'lib/rabbit_feed/event_routing.rb', line 10

def initialize(name, block)
  @name   = name
  @action = block

  validate!
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



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

def action
  @action
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#handle_event(event) ⇒ Object



17
18
19
# File 'lib/rabbit_feed/event_routing.rb', line 17

def handle_event(event)
  action.call event
end