Module: SSD::Internals::Entity::InstanceMethods

Defined in:
lib/ssd/instance_methods.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ssdObject

Returns the value of attribute ssd.



10
11
12
# File 'lib/ssd/instance_methods.rb', line 10

def ssd
  @ssd
end

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/ssd/instance_methods.rb', line 6

def self.included(base)
  @@ssd_name  		= base.new.class.to_s.downcase
end

Instance Method Details

#[]=Object Also known as: append!, save!, store!



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ssd/instance_methods.rb', line 29

def []= 
  @@ssd_path 		= ".ssd/#{@@ssd_name}/#{@ssd}.ssd" 
  @@ssd_db 		= PStore.new @@ssd_path, true
  begin  
    if !@ssd.nil? then 
      @@ssd_db.transaction do
	#todo should be somthing like??? timestamp instead of ssd as a key?? and use .last while reading
	@@ssd_db[Time.now.utc.to_s + "_" + Random.new_seed.to_s ] = self 
      end
    else
      raise 'ssd key can not be nil. see more (documentation url)'  
    end
  end  
end

#transactionObject



22
23
24
25
26
27
# File 'lib/ssd/instance_methods.rb', line 22

def transaction
  @@ssd_db.transaction do
    yield @@ssd_db
    @@ssd_db.commit
  end
end