Class: Moon::Eventable::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/moon/packages/std/mixins/eventable.rb

Overview

Structure for holding event listener information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, filter, callback) ⇒ Listener


24
25
26
# File 'lib/moon/packages/std/mixins/eventable.rb', line 24

def initialize(type, filter, callback)
  @type, @filter, @callback = type, filter, callback
end

Instance Attribute Details

#callbackProc


19
20
21
# File 'lib/moon/packages/std/mixins/eventable.rb', line 19

def callback
  @callback
end

#filterProc


15
16
17
# File 'lib/moon/packages/std/mixins/eventable.rb', line 15

def filter
  @filter
end

#typeClass, Symbol


11
12
13
# File 'lib/moon/packages/std/mixins/eventable.rb', line 11

def type
  @type
end

Instance Method Details

#invoke(event, obj) ⇒ Object


28
29
30
31
# File 'lib/moon/packages/std/mixins/eventable.rb', line 28

def invoke(event, obj)
  return unless @filter.call(event)
  @callback.call(event, obj)
end