Sha256: e36bc28e15ef3de8a5042c33ab34d500856560ff53762831c625714d74120da6

Contents?: true

Size: 858 Bytes

Versions: 6

Compression:

Stored size: 858 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 GlooLang
  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

6 entries across 6 versions & 1 rubygems

Version Path
gloo-lang-0.9.8 lib/gloo_lang/persist/file_storage.rb
gloo-lang-0.9.7 lib/gloo_lang/persist/file_storage.rb
gloo-lang-0.9.6 lib/gloo_lang/persist/file_storage.rb
gloo-lang-0.9.5 lib/gloo_lang/persist/file_storage.rb
gloo-lang-0.9.4 lib/gloo_lang/persist/file_storage.rb
gloo-lang-0.9.3 lib/gloo_lang/persist/file_storage.rb