Class: ValueSemantics::Either
- Inherits:
-
Object
- Object
- ValueSemantics::Either
- Defined in:
- lib/value_semantics/either.rb
Overview
Validator that matches if any of the given subvalidators matches
Instance Attribute Summary collapse
-
#subvalidators ⇒ Object
readonly
Returns the value of attribute subvalidators.
Instance Method Summary collapse
- #===(value) ⇒ Boolean
-
#initialize(subvalidators) ⇒ Either
constructor
A new instance of Either.
Constructor Details
#initialize(subvalidators) ⇒ Either
Returns a new instance of Either.
8 9 10 11 |
# File 'lib/value_semantics/either.rb', line 8 def initialize(subvalidators) @subvalidators = subvalidators freeze end |
Instance Attribute Details
#subvalidators ⇒ Object (readonly)
Returns the value of attribute subvalidators.
6 7 8 |
# File 'lib/value_semantics/either.rb', line 6 def subvalidators @subvalidators end |
Instance Method Details
#===(value) ⇒ Boolean
14 15 16 |
# File 'lib/value_semantics/either.rb', line 14 def ===(value) subvalidators.any? { |sv| sv === value } end |