Sha256: f3afa0de4431976124063830f860acbd1a07af4fcd17331c05303392c35e550c
Contents?: true
Size: 1.02 KB
Versions: 3
Compression:
Stored size: 1.02 KB
Contents
module Faye module Extensible include Logging def add_extension(extension) @extensions ||= [] @extensions << extension extension.added(self) if extension.respond_to?(:added) end 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 def pipe_through_extensions(stage, message, &callback) debug 'Passing through ? extensions: ?', stage, message return callback.call(message) unless @extensions extensions = @extensions.dup pipe = lambda do |message| next callback.call(message) unless message extension = extensions.shift next callback.call(message) unless extension if extension.respond_to?(stage) extension.__send__(stage, message, pipe) else pipe.call(message) end end pipe.call(message) end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
faye-0.8.11 | lib/faye/protocol/extensible.rb |
face-faye-0.8.9 | lib/faye/protocol/extensible.rb |
faye-0.8.9 | lib/faye/protocol/extensible.rb |