Class: Motel::Callbacks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/motel/callbacks.rb

Overview

Base Motel callback interface, provides access to invocable handler

Direct Known Subclasses

Movement, Proximity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}, &block) ⇒ Base

Returns a new instance of Base.



22
23
24
25
# File 'lib/motel/callbacks.rb', line 22

def initialize(args = {}, &block)
  @handler = args[:handler] if args.has_key?(:handler)
  @handler = block if block_given?
end

Instance Attribute Details

#handlerObject

Accessor which will be invoked upon callback event



20
21
22
# File 'lib/motel/callbacks.rb', line 20

def handler
  @handler
end

Instance Method Details

#invoke(args = []) ⇒ Object

FIXME XXX this should be *args instead of args = [] (remove [] around super calls below)



28
29
30
# File 'lib/motel/callbacks.rb', line 28

def invoke(args = [])
  handler.call *args
end