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
175 176 177 |
# File 'lib/rschema.rb', line 175 def key_subschema @key_subschema end |
#value_subschema ⇒ Object
Returns the value of attribute value_subschema
175 176 177 |
# File 'lib/rschema.rb', line 175 def value_subschema @value_subschema end |
Instance Method Details
#inspect ⇒ Object
195 196 197 |
# File 'lib/rschema.rb', line 195 def inspect "hash_of(#{key_subschema.inspect} => #{value_subschema.inspect})" end |
#schema_walk(value, mapper) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/rschema.rb', line 176 def schema_walk(value, mapper) if not value.is_a?(Hash) return RSchema::ErrorDetails.new(value, 'is not a Hash') end value.reduce({}) do |accum, (k, v)| # walk key k_walked, error = RSchema.walk(key_subschema, k, mapper) break error.extend_key_path('.keys') if error # walk value v_walked, error = RSchema.walk(value_subschema, v, mapper) break error.extend_key_path(k) if error accum[k_walked] = v_walked accum end end |