Module: Faye::Extensible
Constant Summary
Constants included from Logging
Instance Method Summary collapse
- #add_extension(extension) ⇒ Object
- #pipe_through_extensions(stage, message, env, &callback) ⇒ Object
- #remove_extension(extension) ⇒ Object
Instance Method Details
#add_extension(extension) ⇒ Object
5 6 7 8 9 |
# File 'lib/faye/protocol/extensible.rb', line 5 def add_extension(extension) @extensions ||= [] @extensions << extension extension.added(self) if extension.respond_to?(:added) end |
#pipe_through_extensions(stage, message, env, &callback) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/faye/protocol/extensible.rb', line 20 def pipe_through_extensions(stage, , env, &callback) debug('Passing through ? extensions: ?', stage, ) return callback.call() unless @extensions extensions = @extensions.dup pipe = lambda do || next callback.call() unless extension = extensions.shift next callback.call() unless extension next pipe.call() unless extension.respond_to?(stage) arity = extension.method(stage).arity if arity >= 3 extension.__send__(stage, , env, pipe) else extension.__send__(stage, , pipe) end end pipe.call() end |
#remove_extension(extension) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/faye/protocol/extensible.rb', line 11 def remove_extension(extension) return unless @extensions @extensions.delete_if do |ext| next false unless ext == extension extension.removed(self) if extension.respond_to?(:removed) true end end |