lib/finix/indifferent_hash.rb in finix-0.16 vs lib/finix/indifferent_hash.rb in finix-1.0.0

- old
+ new

@@ -1,12 +1,25 @@ module Finix class IndifferentHash < ::Hash + + def initialize(*args) + original_hash = args.slice!(0) || {} + self.merge!(original_hash) + end + def method_missing(method, *args, &block) if self.has_key? "#{method}" value = self["#{method}"] - result = value.call - # result.init! args.slice(0) if result.respond_to? :init! - return result + return value.call(*args) if value.respond_to? :call + return value end + end + + def count(*args) + if self.has_key? 'count' + raise Exception.new 'Unsupported block_given exception' if block_given? + return self.send :method_missing, :count, *args + end + super(*args) end end end