Class: Gloo::Persist::FileStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/persist/file_storage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pn, obj = nil) ⇒ FileStorage

Set up a file storage for an object.



16
17
18
19
# File 'lib/gloo/persist/file_storage.rb', line 16

def initialize( pn, obj = nil )
  @obj = obj
  @pn = pn
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



11
12
13
# File 'lib/gloo/persist/file_storage.rb', line 11

def obj
  @obj
end

#pnObject (readonly)

Returns the value of attribute pn.



11
12
13
# File 'lib/gloo/persist/file_storage.rb', line 11

def pn
  @pn
end

Instance Method Details

#loadObject

Load the object from the file.



32
33
34
35
36
37
38
39
40
41
# File 'lib/gloo/persist/file_storage.rb', line 32

def load
  fl = FileLoader.new @pn
  fl.load
  @obj = fl.obj
  if @obj
    $log.debug "Loaded object: #{@obj.name}"
  else
    $log.error "Error loading file at #{@pn}"
  end
end

#saveObject

Save the object to the file.



24
25
26
27
# File 'lib/gloo/persist/file_storage.rb', line 24

def save
  fs = FileSaver.new @pn, @obj
  fs.save
end