Class: BCDD::Contract::Unit::Checking

Inherits:
Object
  • Object
show all
Includes:
Core::Checking
Defined in:
lib/bcdd/contract/unit.rb

Instance Attribute Summary

Attributes included from Core::Checking

#errors, #value

Instance Method Summary collapse

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_messageObject



26
27
28
# File 'lib/bcdd/contract/unit.rb', line 26

def errors_message
  errors.join(', ')
end