Sha256: 69c59d85c03d9947bf5794db5c4edd520c10ff4033910ee88b35d113f076c047
Contents?: true
Size: 1.14 KB
Versions: 10
Compression:
Stored size: 1.14 KB
Contents
module Faye module Extensible include Logging def add_extension(extension) @extensions ||= [] @extensions << extension extension.added if extension.respond_to?(:added) end def remove_extension(extension) return unless @extensions @extensions.delete_if do |ext| if ext == extension extension.removed if extension.respond_to?(:removed) true else false end 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| if !message callback.call(message) else extension = extensions.shift if (!extension) callback.call(message) else if extension.respond_to?(stage) extension.__send__(stage, message, pipe) else pipe.call(message) end end end end pipe.call(message) end end end
Version data entries
10 entries across 10 versions & 1 rubygems