Class: Factbase::Taped::TapedHash

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/taped.rb

Overview

Decorator of Hash.

Instance Method Summary collapse

Constructor Details

#initialize(origin, added) ⇒ TapedHash

Returns a new instance of TapedHash.


82
83
84
85
# File 'lib/factbase/taped.rb', line 82

def initialize(origin, added)
  @origin = origin
  @added = added
end

Instance Method Details

#[](key) ⇒ Object


95
96
97
98
99
# File 'lib/factbase/taped.rb', line 95

def [](key)
  v = @origin[key]
  v = TapedArray.new(v, @origin.object_id, @added) if v.is_a?(Array)
  v
end

#[]=(key, value) ⇒ Object


101
102
103
104
# File 'lib/factbase/taped.rb', line 101

def []=(key, value)
  @origin[key] = value
  @added.append(@origin.object_id)
end

#keysObject


87
88
89
# File 'lib/factbase/taped.rb', line 87

def keys
  @origin.keys
end

#mapObject


91
92
93
# File 'lib/factbase/taped.rb', line 91

def map(&)
  @origin.map(&)
end