Class: Compel::Coercion::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/compel/coercion/result.rb

Direct Known Subclasses

NilResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coerced, value, klass, coercion_error = nil) ⇒ Result

Returns a new instance of Result.



11
12
13
14
15
16
# File 'lib/compel/coercion/result.rb', line 11

def initialize(coerced, value, klass, coercion_error = nil)
  @coerced = coerced
  @value = value
  @klass = klass
  @error = coercion_error.nil? ? standard_error : coercion_error
end

Instance Attribute Details

#coercedObject (readonly)

Returns the value of attribute coerced.



6
7
8
# File 'lib/compel/coercion/result.rb', line 6

def coerced
  @coerced
end

#errorObject (readonly)

Returns the value of attribute error.



6
7
8
# File 'lib/compel/coercion/result.rb', line 6

def error
  @error
end

#klassObject (readonly)

Returns the value of attribute klass.



6
7
8
# File 'lib/compel/coercion/result.rb', line 6

def klass
  @klass
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/compel/coercion/result.rb', line 6

def value
  @value
end

Instance Method Details

#valid?Boolean

Returns:



18
19
20
# File 'lib/compel/coercion/result.rb', line 18

def valid?
  @error.nil?
end