class FayeRails::Filter
Attributes
channel[R]
logger[W]
server[RW]
Public Class Methods
new(channel='/**', direction=:any, block)
click to toggle source
Create a new FayeRails::Filter
which can be passed to Faye::RackAdapter#add_extension.
@param channel
Optional channel name to limit messages to.
@param direction
:in, :out or :any.
@param block
A proc object to be called when filtering messages.
# File lib/faye-rails/filter.rb, line 17 def initialize(channel='/**', direction=:any, block) @channel = channel @block = block raise ArgumentError, "Block cannot be nil" unless block if (direction == :in) || (direction == :any) @in_filter = DSL end if (direction == :out) || (direction == :any) @out_filter = DSL end end
Public Instance Methods
destroy()
click to toggle source
# File lib/faye-rails/filter.rb, line 54 def destroy if server server.remove_extension(self) end end
incoming(message, callback)
click to toggle source
# File lib/faye-rails/filter.rb, line 45 def incoming(message, callback) @in_filter.new(@block, message, channel, callback, :incoming) if @in_filter end
logger()
click to toggle source
# File lib/faye-rails/filter.rb, line 39 def logger if defined?(::Rails) @logger ||= Rails.logger end end
outgoing(message, callback)
click to toggle source
# File lib/faye-rails/filter.rb, line 50 def outgoing(message, callback) @out_filter.new(@block, message, channel, callback, :outgoing) if @out_filter end
respond_to?(method)
click to toggle source
Calls superclass method
# File lib/faye-rails/filter.rb, line 29 def respond_to?(method) if (method == :incoming) !!@in_filter elsif (method == :outgoing) !!@out_filter else super end end