Class: RSchema::EnumSchema

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#subschemaObject

Returns the value of attribute subschema

Returns:

  • (Object)

    the current value of subschema



212
213
214
# File 'lib/rschema.rb', line 212

def subschema
  @subschema
end

#value_setObject

Returns the value of attribute value_set

Returns:

  • (Object)

    the current value of value_set



212
213
214
# File 'lib/rschema.rb', line 212

def value_set
  @value_set
end

Instance Method Details

#schema_walk(value, mapper) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/rschema.rb', line 213

def schema_walk(value, mapper)
  value_walked = if subschema
    v, error = RSchema.walk(subschema, value, mapper)
    return error if error
    v
  else
    value
  end

  if value_set.include?(value_walked)
    value_walked
  else
    RSchema::ErrorDetails.new(value_walked, "#{value_walked} is not a valid enum member")
  end
end