Module: Origami::TypeGuessing
- Included in:
- Dictionary, StandardObject::ClassMethods, Stream
- Defined in:
- lib/origami/object.rb
Instance Method Summary collapse
Instance Method Details
#guess_type(hash) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/origami/object.rb', line 91 def guess_type(hash) return self if (@@type_keys & hash.keys).empty? best_match = self @@signatures.each_pair do |klass, keys| next unless klass < best_match best_match = klass if keys.all? {|k,v| v.is_a?(Set) ? v.include?(hash[k]) : hash[k] == v } end best_match end |