Class: FayeRails::Filter
- Inherits:
-
Object
- Object
- FayeRails::Filter
- Defined in:
- lib/faye-rails/filter.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary (collapse)
-
- (Object) channel
readonly
Returns the value of attribute channel.
- - (Object) logger
-
- (Object) server
Returns the value of attribute server.
Instance Method Summary (collapse)
- - (Object) destroy
- - (Object) incoming(message, callback)
-
- (Filter) initialize(channel = '/**', direction = :any, block)
constructor
Create a new FayeRails::Filter which can be passed to Faye::RackAdapter#add_extension.
- - (Object) outgoing(message, callback)
- - (Boolean) respond_to?(method)
Constructor Details
- (Filter) initialize(channel = '/**', direction = :any, block)
Create a new FayeRails::Filter which can be passed to Faye::RackAdapter#add_extension.
17 18 19 20 21 22 23 24 25 26 27 |
# 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 |
Instance Attribute Details
- (Object) channel (readonly)
Returns the value of attribute channel
5 6 7 |
# File 'lib/faye-rails/filter.rb', line 5 def channel @channel end |
- (Object) logger
39 40 41 42 43 |
# File 'lib/faye-rails/filter.rb', line 39 def logger if defined?(::Rails) @logger ||= Rails.logger end end |
- (Object) server
Returns the value of attribute server
4 5 6 |
# File 'lib/faye-rails/filter.rb', line 4 def server @server end |
Instance Method Details
- (Object) destroy
54 55 56 57 58 |
# File 'lib/faye-rails/filter.rb', line 54 def destroy if server server.remove_extension(self) end end |
- (Object) incoming(message, callback)
45 46 47 |
# File 'lib/faye-rails/filter.rb', line 45 def incoming(, callback) @in_filter.new(@block, , channel, callback, :incoming) if @in_filter end |
- (Object) outgoing(message, callback)
50 51 52 |
# File 'lib/faye-rails/filter.rb', line 50 def outgoing(, callback) @out_filter.new(@block, , channel, callback, :outgoing) if @out_filter end |
- (Boolean) respond_to?(method)
29 30 31 32 33 34 35 36 37 |
# 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 |