Class: FayeRails::Filter
- Inherits:
-
Object
- Object
- FayeRails::Filter
- Defined in:
- lib/faye-rails/filter.rb
Defined Under Namespace
Classes: DSL
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
- #logger ⇒ Object
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
- #destroy ⇒ Object
- #incoming(message, callback) ⇒ Object
-
#initialize(channel = '/**', direction = :any, block) ⇒ Filter
constructor
Create a new FayeRails::Filter which can be passed to Faye::RackAdapter#add_extension.
- #outgoing(message, callback) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(channel = '/**', direction = :any, block) ⇒ Filter
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
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
5 6 7 |
# File 'lib/faye-rails/filter.rb', line 5 def channel @channel end |
#logger ⇒ Object
39 40 41 42 43 |
# File 'lib/faye-rails/filter.rb', line 39 def logger if defined?(::Rails) @logger ||= Rails.logger end end |
#server ⇒ Object
Returns the value of attribute server.
4 5 6 |
# File 'lib/faye-rails/filter.rb', line 4 def server @server end |
Instance Method Details
#destroy ⇒ Object
54 55 56 57 58 |
# File 'lib/faye-rails/filter.rb', line 54 def destroy if server server.remove_extension(self) end end |
#incoming(message, callback) ⇒ Object
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 |
#outgoing(message, callback) ⇒ Object
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 |
#respond_to?(method) ⇒ Boolean
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 |