Sha256: a9bc8c46bc7122dd4332fe39b278d83fd953d34e19b70a921c352269db6f945e
Contents?: true
Size: 608 Bytes
Versions: 2
Compression:
Stored size: 608 Bytes
Contents
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}"] 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
finix-1.0.1 | lib/finix/indifferent_hash.rb |
finix-1.0.0 | lib/finix/indifferent_hash.rb |