Sha256: bea8a85a907edf1948da004186fef636d6543f1e66469f7ad46aa1ac882a867c

Contents?: true

Size: 919 Bytes

Versions: 5

Compression:

Stored size: 919 Bytes

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# Helper class takes an object and writes it to a file.
#

module Gloo
  module Persist
    class FileStorage

      attr_reader :obj, :pn

      #
      # Set up a file storage for an object.
      #
      def initialize( engine, pn, obj = nil )
        @engine = engine
        @obj = obj
        @pn = pn
      end

      #
      # Save the object to the file.
      #
      def save
        fs = FileSaver.new( @engine, @pn, @obj )
        fs.save
      end

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

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gloo-3.7.0 lib/gloo/persist/file_storage.rb
gloo-3.6.2 lib/gloo/persist/file_storage.rb
gloo-3.6.1 lib/gloo/persist/file_storage.rb
gloo-3.6.0 lib/gloo/persist/file_storage.rb
gloo-3.5.0 lib/gloo/persist/file_storage.rb