class FayeRails::RackAdapter::RoutingExtension
Public Class Methods
new()
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 93 def initialize @default = :allow @mappings = {} end
Public Instance Methods
allow_unknown_channels!()
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 128 def allow_unknown_channels! @default = :allow end
block_unknown_channels!()
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 120 def block_unknown_channels! @default = :block end
drop_unknown_channels!()
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 124 def drop_unknown_channels! @default = :drop end
incoming(message, callback)
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 98 def incoming(message, callback) if message['channel'] == '/meta/subscribe' take_action_for message, callback, message['subscription'] elsif message['channel'] == '/meta/unsubscribe' take_action_for message, callback, message['subscription'] elsif FayeRails::Matcher.match? '/meta/*', message['channel'] callback.call(message) elsif FayeRails::Matcher.match? '/service/**', message['channel'] callback.call(message) else take_action_for message, callback, message['channel'] end end
map(channel, controller)
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 112 def map(channel, controller) if FayeRails::Matcher.match? '/**', channel (@mappings[channel] ||= []) << controller else raise ArgumentError, "Invalid channel name: #{channel}" end end
take_action_for(message, callback, test='')
click to toggle source
# File lib/faye-rails/rack_adapter.rb, line 132 def take_action_for(message, callback, test='') if @mappings.keys.select { |glob| FayeRails::Matcher.match? glob, test }.size > 0 callback.call(message) elsif @default == :block message['error'] = "Permission denied" callback.call(message) elsif @default == :drop callback.call(nil) elsif @default == :allow callback.call(message) else callback.call(nil) end end