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(engine, pn, obj = nil) ⇒ FileStorage

Set up a file storage for an object.



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

def initialize( engine, pn, obj = nil )
  @engine = engine
  @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.



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

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

#saveObject

Save the object to the file.



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

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