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.
49 50 51 52 53 54 |
# File 'lib/meddler.rb', line 49 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.
48 49 50 |
# File 'lib/meddler.rb', line 48 def app @app end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
48 49 50 |
# File 'lib/meddler.rb', line 48 def filters @filters end |
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
48 49 50 |
# File 'lib/meddler.rb', line 48 def rules @rules end |
#skip_app ⇒ Object (readonly)
Returns the value of attribute skip_app.
48 49 50 |
# File 'lib/meddler.rb', line 48 def skip_app @skip_app end |
Instance Method Details
#call(env) ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/meddler.rb', line 56 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(env) else skip_app.call(env) end end |