Class: Padrino::Filter
- Defined in:
- padrino-core/lib/padrino-core/filter.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
- #apply?(request) ⇒ Boolean
-
#initialize(mode, scoped_controller, options, args, &block) ⇒ Filter
constructor
A new instance of Filter.
- #to_proc ⇒ Object
Constructor Details
#initialize(mode, scoped_controller, options, args, &block) ⇒ Filter
Returns a new instance of Filter.
5 6 7 8 9 10 11 |
# File 'padrino-core/lib/padrino-core/filter.rb', line 5 def initialize(mode, scoped_controller, , args, &block) @mode = mode @scoped_controller = scoped_controller @options = @args = args @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'padrino-core/lib/padrino-core/filter.rb', line 3 def block @block end |
Instance Method Details
#apply?(request) ⇒ Boolean
13 14 15 16 |
# File 'padrino-core/lib/padrino-core/filter.rb', line 13 def apply?(request) detect = match_with_arguments?(request) || (request) detect ^ !@mode end |
#to_proc ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'padrino-core/lib/padrino-core/filter.rb', line 18 def to_proc if @args.empty? && @options.empty? block else filter = self proc { instance_eval(&filter.block) if filter.apply?(request) } end end |