Class: BCDD::Contract::Unit::Checking
- Inherits:
-
Object
- Object
- BCDD::Contract::Unit::Checking
- Includes:
- Core::Checking
- Defined in:
- lib/bcdd/contract/unit.rb
Instance Attribute Summary
Attributes included from Core::Checking
Instance Method Summary collapse
- #errors_message ⇒ Object
-
#initialize(strategy, value) ⇒ Checking
constructor
A new instance of Checking.
Methods included from Core::Checking
#invalid?, #raise_validation_errors!, #valid?, #value_or_raise_validation_errors!
Constructor Details
#initialize(strategy, value) ⇒ Checking
Returns a new instance of Checking.
18 19 20 21 22 23 24 |
# File 'lib/bcdd/contract/unit.rb', line 18 def initialize(strategy, value) @value = value errors = [].tap { |err| strategy.call(value, err) } @errors = errors.flat_map { |error| format(error, value) } end |
Instance Method Details
#errors_message ⇒ Object
26 27 28 |
# File 'lib/bcdd/contract/unit.rb', line 26 def errors.join(', ') end |