Module: Persistence::Object::Complex::Hash::ObjectInstance

Included in:
Persistence::Object::Complex::Hash
Defined in:
lib/persistence/object/complex/hash/object_instance.rb

Overview

Instance methods for hash objects enabled with persistence capabilities.

Instance Method Summary collapse

Instance Method Details

#load_persistence_value(attribute_name, attribute_value) ⇒ Object

load_persistence_value #


59
60
61
# File 'lib/persistence/object/complex/hash/object_instance.rb', line 59

def load_persistence_value( attribute_name, attribute_value )
  self[ attribute_name ] = attribute_value
end

#persist(*args) ⇒ Object

persist #


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/persistence/object/complex/hash/object_instance.rb', line 11

def persist( *args )
  
  index, key, no_key = parse_object_args_for_index_value_no_value( args, true )
  
  if index
    global_id = index.get_object_id( key )
  elsif key
    global_id = key
  else
    global_id = persistence_id
  end
  
  port_hash = persistence_bucket.adapter_bucket.get_object( global_id )

  port_hash.each do |this_key, this_value|
    if this_value.is_a?( ::Persistence::Object::Complex::ComplexObject )
      self[ this_key ] = this_value.persist
    else
      self[ this_key ] = this_value
    end
  end
  
  return self
  
end

#persistence_hash_to_portObject

persistence_hash_to_port #


41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/persistence/object/complex/hash/object_instance.rb', line 41

def persistence_hash_to_port

  hash_to_port = ::Persistence::Object::Complex::Attributes::HashToPort.new
  hash_to_port.persistence_object = self
  
  self.each do |key, data|
    key = persist_as_sub_object_or_attribute_and_return_id_or_value( key )
    hash_to_port[ key ] = data
  end

  return hash_to_port
  
end