Class: ValueSemantics::Either
- Inherits:
-
Object
- Object
- ValueSemantics::Either
- Defined in:
- lib/value_semantics.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.
341 342 343 344 |
# File 'lib/value_semantics.rb', line 341 def initialize(subvalidators) @subvalidators = subvalidators freeze end |
Instance Attribute Details
#subvalidators ⇒ Object (readonly)
Returns the value of attribute subvalidators.
339 340 341 |
# File 'lib/value_semantics.rb', line 339 def subvalidators @subvalidators end |
Instance Method Details
#===(value) ⇒ Boolean
347 348 349 |
# File 'lib/value_semantics.rb', line 347 def ===(value) subvalidators.any? { |sv| sv === value } end |