Class: ValueSemantics::Either

Inherits:
Object
  • Object
show all
Defined in:
lib/value_semantics.rb

Overview

Validator that matches if any of the given subvalidators matches

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#subvalidatorsObject (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

Returns:

  • (Boolean)


347
348
349
# File 'lib/value_semantics.rb', line 347

def ===(value)
  subvalidators.any? { |sv| sv === value }
end