Class: Rodent::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rodent/base.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.error_handlerObject

Returns the value of attribute error_handler.



5
6
7
# File 'lib/rodent/base.rb', line 5

def error_handler
  @error_handler
end

.instanceObject (readonly)

Returns the value of attribute instance.



4
5
6
# File 'lib/rodent/base.rb', line 4

def instance
  @instance
end

.listenersObject (readonly)

Returns the value of attribute listeners.



4
5
6
# File 'lib/rodent/base.rb', line 4

def listeners
  @listeners
end

Class Method Details

.bindObject



22
23
24
25
26
# File 'lib/rodent/base.rb', line 22

def bind
  listeners.each do |listener|
    listener.bind(error_handler)
  end
end

.listen(type, &block) ⇒ Object



18
19
20
# File 'lib/rodent/base.rb', line 18

def listen(type, &block)
  listeners << Rodent::Listener.new(type, &block)
end

.route(type) ⇒ Object



11
12
13
14
15
16
# File 'lib/rodent/base.rb', line 11

def route(type)
  @listeners.each do |listener|
    return listener if type == listener.type
  end
  nil
end