Class: Permittable::FinalizeRunner
- Inherits:
-
Object
- Object
- Permittable::FinalizeRunner
- Defined in:
- lib/permittable.rb
Overview
The self a finalize block runs on. Deliberately bare — no controller
delegation — so a contract cannot grow request-state dependencies; its
whole vocabulary is the hash it receives plus violate!.
Instance Method Summary collapse
-
#initialize(violations) ⇒ FinalizeRunner
constructor
A new instance of FinalizeRunner.
-
#violate!(param, code) ⇒ Object
Records ONE violation and halts the finalize block immediately (the code after a violate! call never runs, so it can assume the checked invariant).
Constructor Details
#initialize(violations) ⇒ FinalizeRunner
Returns a new instance of FinalizeRunner.
501 502 503 |
# File 'lib/permittable.rb', line 501 def initialize(violations) @violations = violations end |
Instance Method Details
#violate!(param, code) ⇒ Object
Records ONE violation and halts the finalize block immediately (the code after a violate! call never runs, so it can assume the checked invariant). The contract then fails as a normal 422.
508 509 510 511 |
# File 'lib/permittable.rb', line 508 def violate!(param, code) @violations << { param: param.to_s, code: code.to_s } throw :permittable_finalize_halt end |