Sha256: b91e480d766fdc45c33d93a4e89ca17155390b9d389cd78afa1f858d8046e798
Contents?: true
Size: 785 Bytes
Versions: 3
Compression:
Stored size: 785 Bytes
Contents
class Hash class Accessible < Indifferent def self.make_accessible(value) if value.kind_of? Hash self.new value elsif value.kind_of? ::Array Array.new value else value end end class Array < SimpleDelegator def initialize(array) super array.map { |v| Accessible.make_accessible v } end def push(value) super Accessible.make_accessible(value) end alias_method :<<, :push end def []=(key, value) super key, self.class.make_accessible(value) end private def method_missing(method, *args, &block) if method.to_s.end_with? '=' key = method[0..-2] self[key] = args[0] else self[method] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hash_ext-0.2.3 | lib/hash_ext/accessible.rb |
hash_ext-0.2.2 | lib/hash_ext/accessible.rb |
hash_ext-0.2.1 | lib/hash_ext/accessible.rb |