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



193
194
195
# File 'lib/rschema.rb', line 193

def subschema
  @subschema
end

#value_setObject

Returns the value of attribute value_set

Returns:

  • (Object)

    the current value of value_set



193
194
195
# File 'lib/rschema.rb', line 193

def value_set
  @value_set
end

Instance Method Details

#schema_walk(value, mapper) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/rschema.rb', line 194

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} is not a valid enum member")
  end
end