Class: Vetinari::Callback
- Inherits:
-
Object
- Object
- Vetinari::Callback
- Includes:
- Celluloid
- Defined in:
- lib/vetinari/callback.rb
Instance Attribute Summary collapse
-
#container ⇒ Object
writeonly
Sets the attribute container.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(event, options, proc, container, uuid) ⇒ Callback
constructor
A new instance of Callback.
- #inspect ⇒ Object
- #remove ⇒ Object
- #remove_and_terminate ⇒ Object
Constructor Details
#initialize(event, options, proc, container, uuid) ⇒ Callback
Returns a new instance of Callback.
8 9 10 11 12 13 14 |
# File 'lib/vetinari/callback.rb', line 8 def initialize(event, , proc, container, uuid) @event = event @options = @proc = proc @container = container @uuid = uuid end |
Instance Attribute Details
#container=(value) ⇒ Object (writeonly)
Sets the attribute container
6 7 8 |
# File 'lib/vetinari/callback.rb', line 6 def container=(value) @container = value end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
5 6 7 |
# File 'lib/vetinari/callback.rb', line 5 def event @event end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/vetinari/callback.rb', line 16 def call(env) begin @proc.call(env) if matching?(env) rescue => e loggers = @container.bot.config.loggers loggers.error "-- #{e.class}: #{e.}" e.backtrace.each { |line| loggers.error("-- #{line}") } end end |
#inspect ⇒ Object
34 35 36 37 38 39 |
# File 'lib/vetinari/callback.rb', line 34 def inspect event = @event.inspect = @options.inspect uuid = @uuid.inspect "#<Callback event=#{event} options=#{} uuid=#{uuid}>" end |
#remove ⇒ Object
26 27 28 |
# File 'lib/vetinari/callback.rb', line 26 def remove @container.remove(@event, @uuid) end |
#remove_and_terminate ⇒ Object
30 31 32 |
# File 'lib/vetinari/callback.rb', line 30 def remove_and_terminate @container.remove(@event, @uuid, true) end |