Module: Faye::Extensible
Constant Summary
Constants included
from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary
Attributes included from Logging
#log_level
Instance Method Summary
collapse
Methods included from Logging
#log
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 if extension.respond_to?(:added)
end
|
#pipe_through_extensions(stage, message, &callback) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/faye/protocol/extensible.rb', line 23
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
|
#remove_extension(extension) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/faye/protocol/extensible.rb', line 11
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
|