Class: Eventish::SimpleEvent

Inherits:
Object
  • Object
show all
Extended by:
EventApi
Defined in:
lib/eventish/simple_event.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EventApi

<=>, after_event, before_event, event_name, priority, subscribe, subscribe_all, unsubscribe

Class Method Details

.trigger(target, args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/eventish/simple_event.rb', line 16

def trigger(target, args, &block)
  event = new
  return unless event.callable?(target)

  before_event.each { |plugin| plugin.call(target, args, event: event, hook: :before, &block) }
  event.call(target, args, &block)
  after_event.each { |plugin| plugin.call(target, args, event: event, hook: :after, &block) }
  event
end

Instance Method Details

#call(_target, _args, &_block) ⇒ Object

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/eventish/simple_event.rb', line 5

def call(_target, _args, &_block)
  raise NotImplementedError
end

#callable?(_target) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/eventish/simple_event.rb', line 9

def callable?(_target)
  true
end