Class: Phronomy::Guardrail::Base
- Inherits:
-
Object
- Object
- Phronomy::Guardrail::Base
- Defined in:
- lib/phronomy/guardrail/base.rb
Overview
Abstract base class for all guardrails.
Subclasses override #check to validate input or output. Call #fail! inside #check to reject with a reason.
Direct Known Subclasses
Instance Method Summary collapse
-
#check(value) ⇒ Object
Validate the value.
-
#run!(value) ⇒ Object
Run the check, raising GuardrailError on failure.
Instance Method Details
#check(value) ⇒ Object
Validate the value. Subclasses must implement this method.
20 21 22 |
# File 'lib/phronomy/guardrail/base.rb', line 20 def check(value) raise NotImplementedError, "#{self.class}#check is not implemented" end |
#run!(value) ⇒ Object
Run the check, raising GuardrailError on failure.
27 28 29 30 |
# File 'lib/phronomy/guardrail/base.rb', line 27 def run!(value) check(value) value end |