lib/excon/hypermedia/helpers/collection.rb in excon-hypermedia-0.4.3 vs lib/excon/hypermedia/helpers/collection.rb in excon-hypermedia-0.5.0

- old
+ new

@@ -10,11 +10,11 @@ # module Collection include Enumerable def initialize(collection = {}) - @collection ||= collection + @collection ||= collection.to_h to_properties end def each(&block) collection.each(&block) @@ -31,9 +31,24 @@ def [](key) to_property(key) end private + + # method_missing + # + # Collections can be accessed using both the "dot notation" and the hash + # notation: + # + # collection.hello_world + # collection['hello_world'] + # + # The second notation returns `nil` on missing keys, the first should do + # as well. + # + def method_missing(_) + nil + end def to_properties collection.each do |key, value| key = key.downcase next unless /[@$"]/ !~ key.to_sym.inspect