Sha256: 0079bc46db810033e372fc81ad8daf6776d813df4107b54085b63990aa85937e

Contents?: true

Size: 854 Bytes

Versions: 9

Compression:

Stored size: 854 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( pn, obj = nil )
        @obj = obj
        @pn = pn
      end

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

      #
      # Load the object from the file.
      #
      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

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
gloo-0.8.0 lib/gloo/persist/file_storage.rb
gloo-0.7.7 lib/gloo/persist/file_storage.rb
gloo-0.7.6 lib/gloo/persist/file_storage.rb
gloo-0.7.5 lib/gloo/persist/file_storage.rb
gloo-0.7.4 lib/gloo/persist/file_storage.rb
gloo-0.7.3 lib/gloo/persist/file_storage.rb
gloo-0.7.2 lib/gloo/persist/file_storage.rb
gloo-0.7.1 lib/gloo/persist/file_storage.rb
gloo-0.7.0 lib/gloo/persist/file_storage.rb