Class: RSchema::GenericHashSchema
- Inherits:
-
Struct
- Object
- Struct
- RSchema::GenericHashSchema
- Defined in:
- lib/rschema.rb
Instance Attribute Summary collapse
-
#key_subschema ⇒ Object
Returns the value of attribute key_subschema.
-
#value_subschema ⇒ Object
Returns the value of attribute value_subschema.
Instance Method Summary collapse
Instance Attribute Details
#key_subschema ⇒ Object
Returns the value of attribute key_subschema
137 138 139 |
# File 'lib/rschema.rb', line 137 def key_subschema @key_subschema end |
#value_subschema ⇒ Object
Returns the value of attribute value_subschema
137 138 139 |
# File 'lib/rschema.rb', line 137 def value_subschema @value_subschema end |
Instance Method Details
#schema_walk(value, mapper) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/rschema.rb', line 138 def schema_walk(value, mapper) if not value.is_a?(Hash) return RSchema::ErrorDetails.new('is not a Hash') end value.reduce({}) do |accum, (k, v)| # walk key k_walked, error = RSchema.walk(key_subschema, k, mapper) break RSchema::ErrorDetails.new({'has invalid key, where' => error.details}) if error # walk value v_walked, error = RSchema.walk(value_subschema, v, mapper) break RSchema::ErrorDetails.new({k => error.details}) if error accum[k_walked] = v_walked accum end end |