Class: Meddler::PreInterceptor
- Inherits:
-
Object
- Object
- Meddler::PreInterceptor
- Defined in:
- lib/meddler.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
-
#skip_app ⇒ Object
readonly
Returns the value of attribute skip_app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, skip_app, rules, filters) ⇒ PreInterceptor
constructor
A new instance of PreInterceptor.
Constructor Details
#initialize(app, skip_app, rules, filters) ⇒ PreInterceptor
Returns a new instance of PreInterceptor.
62 63 64 65 66 67 |
# File 'lib/meddler.rb', line 62 def initialize(app, skip_app, rules, filters) @app = app @skip_app = skip_app @rules = rules @filters = filters end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
61 62 63 |
# File 'lib/meddler.rb', line 61 def app @app end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
61 62 63 |
# File 'lib/meddler.rb', line 61 def filters @filters end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
61 62 63 |
# File 'lib/meddler.rb', line 61 def rules @rules end |
#skip_app ⇒ Object (readonly)
Returns the value of attribute skip_app.
61 62 63 |
# File 'lib/meddler.rb', line 61 def skip_app @skip_app end |
Instance Method Details
#call(env) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/meddler.rb', line 69 def call(env) request = Rack::Request.new(env) if rules.nil? || rules.all?{|f| f.call(request)} filters && filters.each{|f| f.call(request)} app.call(request.env) else skip_app.call(request.env) end end |