Method: Spider::Dispatcher::ClassMethods#check_action

Defined in:
lib/spiderfw/controller/dispatcher.rb

#check_action(action, check) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/spiderfw/controller/dispatcher.rb', line 263

def check_action(action, check)
    checks = check.is_a?(Array) ? check : [check]
    action = action.to_s
    action = default_action if action == ''
    action = action[0..-1] if action[-1].chr == '/'
    checks.each do |check|
        if check.is_a?(String)
            return true if (action == check || (action[-1].chr == '/' && action[0..-2] == check))
        elsif check.is_a?(Regexp)
            return true if action =~ check
        elsif check.is_a?(Proc)
            return true if check.call(action)
        elsif (check.is_a?(Symbol))
            first, rest = action.split('/', 2)
            return true if first && first.to_sym == check
        end
    end
    return false
end