lib/faye-rails/rack_adapter.rb in faye-rails-2.0.0 vs lib/faye-rails/rack_adapter.rb in faye-rails-2.0.1

- old
+ new

@@ -38,11 +38,11 @@ # error "Permission denied." def map(opts) if opts.is_a? Hash opts.each do |channel, controller| if channel.is_a? String - if File.fnmatch?('/**', channel) + if FayeRails::Matcher.match? '/**', channel routing_extension.map(channel, controller) else raise ArgumentError, "Invalid channel: #{channel}" end elsif channel == :default @@ -107,21 +107,21 @@ 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 File.fnmatch?('/meta/*', message['channel']) + elsif FayeRails::Matcher.match? '/meta/*', message['channel'] callback.call(message) - elsif File.fnmatch?('/service/**', message['channel']) + elsif FayeRails::Matcher.match? '/service/**', message['channel'] callback.call(message) else take_action_for message, callback, message['channel'] end end def map(channel, controller) - if File.fnmatch?('/**', channel) + if FayeRails::Matcher.match? '/**', channel (@mappings[channel] ||= []) << controller else raise ArgumentError, "Invalid channel name: #{channel}" end end @@ -137,10 +137,10 @@ def allow_unknown_channels! @default = :allow end def take_action_for(message, callback, test='') - if @mappings.keys.select { |glob| File.fnmatch?(glob,test) }.size > 0 + 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