Method: Spider::Controller.before

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

.before(conditions, method, params = {}) ⇒ void

This method returns an undefined value.

Defines a method that will be called before the controller’s before, if the action matches the given conditions. Example:

before(/^list_/, :before_lists)

will call the method before_lists if the action starts with ‘list_’

Parameters:

  • conditions (String|Regexp|Proc|Symbol|Array)

    what will be checked against the action

  • method (Symbol)

    The method to be called if the conditions match.

  • params (Hash) (defaults to: {})

    may contain :unless => true: in this case, the conditions will be inverted, that is, the method will be executed unless the conditions match.



57
58
59
60
61
# File 'lib/spiderfw/controller/controller.rb', line 57

def before(conditions, method, params={})
    @dispatch_methods ||= {}
    @dispatch_methods[:before] ||= []
    @dispatch_methods[:before] << [conditions, method, params]
end