Method: Higgs::TransactionContext#initialize

Defined in:
lib/higgs/tman.rb

#initialize(lock_handler, storage, snapshot, master_cache, secondary_cache, decode, encode) ⇒ TransactionContext

Returns a new instance of TransactionContext.



171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/higgs/tman.rb', line 171

def initialize(lock_handler, storage, snapshot, master_cache, secondary_cache, decode, encode)
  @lock_handler = lock_handler
  @storage = storage
  @snapshot = snapshot
  @master_cache = master_cache
  @secondary_cache = secondary_cache
  @decode = decode
  @encode = encode

  @local_data_cache = Hash.new{|hash, key|
    if (@snapshot.key? @storage, key) then
      if (string_only(key)) then
        hash[key] = @snapshot.fetch(key, :data) { @master_cache[key] }
      else
        hash[key] = @decode.call(@snapshot.fetch(key, :data) { @master_cache[key] })
      end
    end
  }

  @local_properties_cache = Hash.new{|hash, key|
    hash[key] = @snapshot.fetch(key, :properties) {
      deep_copy(@storage.fetch_properties(key))
    } || { 'system_properties' => {}, 'custom_properties' => {} }
  }

  @locked_map = {}
  @locked_map.default = false
  @update_system_properties = {}
  @update_custom_properties = {}
  @ope_map = {}
end