Class: Serf::Middleware::PolicyChecker
- Inherits:
-
Object
- Object
- Serf::Middleware::PolicyChecker
- Defined in:
- lib/serf/middleware/policy_checker.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#policy_chain ⇒ Object
readonly
Returns the value of attribute policy_chain.
Instance Method Summary collapse
-
#call(parcel) ⇒ Object
Iterates the policy chain and does a check for each policy.
-
#initialize(app, *args) ⇒ PolicyChecker
constructor
A new instance of PolicyChecker.
Constructor Details
#initialize(app, *args) ⇒ PolicyChecker
Returns a new instance of PolicyChecker.
10 11 12 13 14 |
# File 'lib/serf/middleware/policy_checker.rb', line 10 def initialize(app, *args) opts = Optser. args @app = app @policy_chain = opts.get :policy_chain, [] end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/serf/middleware/policy_checker.rb', line 7 def app @app end |
#policy_chain ⇒ Object (readonly)
Returns the value of attribute policy_chain.
8 9 10 |
# File 'lib/serf/middleware/policy_checker.rb', line 8 def policy_chain @policy_chain end |
Instance Method Details
#call(parcel) ⇒ Object
Iterates the policy chain and does a check for each policy. Assumes that policies will raise errors on any policy failure.
19 20 21 22 23 24 |
# File 'lib/serf/middleware/policy_checker.rb', line 19 def call(parcel) policy_chain.each do |policy| policy.check! parcel end app.call parcel end |