Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/yas/hash.rb
Instance Method Summary collapse
Instance Method Details
#slice(*keys) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/yas/hash.rb', line 14 def slice *keys keys.flatten! data = keys.inject({}) do |memo, key| memo[key] = self[key] if self[key] memo end data end |
#validate(schema) ⇒ Object
3 4 5 6 |
# File 'lib/yas/hash.rb', line 3 def validate schema copy = Marshal.load(Marshal.dump(self)) schema.validate(copy) if schema.respond_to?(:validate) end |
#validate!(schema) ⇒ Object
9 10 11 |
# File 'lib/yas/hash.rb', line 9 def validate! schema schema.validate(self) if schema.respond_to?(:validate) end |