Class: EventMachine::Hooks::EventMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/event_machine/hooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(controller_class, name, &block) ⇒ EventMeta

Returns a new instance of EventMeta.



85
86
87
88
89
# File 'lib/event_machine/hooks.rb', line 85

def initialize(controller_class, name, &block)
  @controller_class = controller_class
  @action = name
  self.instance_eval(&block)
end

Instance Method Details

#call_after(controller_instance) ⇒ Object



95
96
97
# File 'lib/event_machine/hooks.rb', line 95

def call_after(controller_instance)
  controller_instance.instance_eval(&@after) if @after
end

#call_before(controller_instance) ⇒ Object



91
92
93
# File 'lib/event_machine/hooks.rb', line 91

def call_before(controller_instance)
  controller_instance.instance_eval(&@before) if @before
end

#match_event?(clazz, action_name) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/event_machine/hooks.rb', line 99

def match_event?(clazz, action_name)
  @controller_class == clazz && @action.to_s == action_name.to_s
end