Sha256: 57bf7b17e4a39cc27894c9fb24f2507735b644087df179f4633adc62fae9471a
Contents?: true
Size: 952 Bytes
Versions: 1
Compression:
Stored size: 952 Bytes
Contents
require 'forwardable' module InheritableAccessors class InheritableHash attr_accessor :__local_values__ attr_reader :__parent__ extend Forwardable WRITE_METHODS = %w{ []= initialize merge! store } READ_METHODS = %w{ == [] each each_pair each_value empty? eql? fetch flatten has_key? has_value? hash include? index inspect invert key key? keys length member? merge pretty_print rehash select size to_a to_h to_s value? values } def_delegators :@__local_values__, *WRITE_METHODS delegate READ_METHODS => :to_hash def initialize(prototype=nil) @__local_values__ = Hash.new @__parent__ = prototype end def to_hash if !!__parent__ __parent__.to_hash.merge(__local_values__) else __local_values__.clone end end def inherit_copy InheritableHash.new(self) end alias :initialize_copy :inherit_copy end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inheritable_accessors-0.1.1 | lib/inheritable_accessors/inheritable_hash.rb |