Module: Dirty::Hash

Included in:
DirtyHashy, DirtyIndifferentHashy
Defined in:
lib/dirty/hash.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dirty/hash.rb', line 4

def self.included(base)
  base.method_defined?(:regular_writer).tap do |defined|
    base.send :include, InstanceMethods
    unless defined
      base.send :alias_method, :_store, :store
      base.send :alias_method, :store, :regular_writer
      base.send :alias_method, :[]=, :store
      base.send :define_method, :update do |other|
        other.each{|key, value| store key, value}
      end
      base.send :alias_method, :merge!, :update
    end
  end
end