Sha256: 4656cb4464245fdda0338bee0a59a3f3a3acfff8237c5ab1aea502fcd18b7a5d

Contents?: true

Size: 838 Bytes

Versions: 8

Compression:

Stored size: 838 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

8 entries across 8 versions & 1 rubygems

Version Path
gloo-0.6.1 lib/gloo/persist/file_storage.rb
gloo-0.6.0 lib/gloo/persist/file_storage.rb
gloo-0.5.4 lib/gloo/persist/file_storage.rb
gloo-0.5.3 lib/gloo/persist/file_storage.rb
gloo-0.5.2 lib/gloo/persist/file_storage.rb
gloo-0.5.1 lib/gloo/persist/file_storage.rb
gloo-0.5.0 lib/gloo/persist/file_storage.rb
gloo-0.4.0 lib/gloo/persist/file_storage.rb