Class: DpStmMap::ObjectTransactionWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dp_stm_map/ObjectStore.rb

Instance Method Summary collapse

Constructor Details

#initialize(tx) ⇒ ObjectTransactionWrapper

Returns a new instance of ObjectTransactionWrapper.



19
20
21
# File 'lib/dp_stm_map/ObjectStore.rb', line 19

def initialize tx
  @tx=tx
end

Instance Method Details

#[](domain, key) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/dp_stm_map/ObjectStore.rb', line 27

def [] domain, key
  raw=@tx[domain_key(domain,key)]
  if (raw == nil)
    nil
  else
    YAML::load(raw)
  end
end

#[]=(domain, key, value) ⇒ Object



23
24
25
# File 'lib/dp_stm_map/ObjectStore.rb', line 23

def []= domain, key, value
  @tx[domain_key(domain,key)]=value == nil ? nil : YAML::dump(value)
end

#domain_key(domain, key) ⇒ Object



40
41
42
# File 'lib/dp_stm_map/ObjectStore.rb', line 40

def domain_key domain, key
  "%s:%s" % [domain.to_s, key.to_s]
end

#has_key?(domain, key) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/dp_stm_map/ObjectStore.rb', line 36

def has_key? domain, key
  @tx.has_key?(domain_key(domain,key))
end