Sha256: cdd8e3e8e644f34a8f934171807d4ae935194fd325fdb440d62be360d5a7959e
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# Use colorize gem to color/fmt output require 'colorize' module Pushwagner # Shamefully copied from ActiveSupport class HashWithIndifferentAccess < ::Hash def initialize(hash={}) super() hash.each do |key, value| self[convert_key(key)] = value end end def [](key) super(convert_key(key)) end def []=(key, value) super(convert_key(key), value) end def delete(key) super(convert_key(key)) end def values_at(*indices) indices.collect { |key| self[convert_key(key)] } end def merge(other) dup.merge!(other) end def merge!(other) other.each do |key, value| self[convert_key(key)] = value end self end def to_hash Hash.new(default).merge!(self) end protected def convert_key(key) key.is_a?(Symbol) ? key.to_s : key end def method_missing(method, *args, &block) method = method.to_s if method =~ /^(\w+)\?$/ if args.empty? !!self[$1] else self[$1] == args.first end else self[method] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pushwagner-0.0.1.8 | lib/pushwagner/ext.rb |