Class: RSchema::Coercers::Any

Inherits:
Object
  • Object
show all
Defined in:
lib/rschema/coercers/any.rb

Defined Under Namespace

Classes: Builder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subcoercers) ⇒ Any


11
12
13
# File 'lib/rschema/coercers/any.rb', line 11

def initialize(subcoercers)
  @subcoercers = subcoercers
end

Instance Attribute Details

#subcoercersObject (readonly)

Returns the value of attribute subcoercers


5
6
7
# File 'lib/rschema/coercers/any.rb', line 5

def subcoercers
  @subcoercers
end

Class Method Details

.[](*subbuilders) ⇒ Object


7
8
9
# File 'lib/rschema/coercers/any.rb', line 7

def self.[](*subbuilders)
  Builder.new(subbuilders)
end

Instance Method Details

#call(value) ⇒ Object


15
16
17
18
19
20
21
# File 'lib/rschema/coercers/any.rb', line 15

def call(value)
  subcoercers.each do |coercer|
    result = coercer.call(value)
    return result if result.valid?
  end
  Result.failure
end