Sha256: 404f2d87f4aa50bb9d6b15ad87a37f25f652aa302b2bdd67e2531e01dc55f68f
Contents?: true
Size: 711 Bytes
Versions: 1
Compression:
Stored size: 711 Bytes
Contents
require 'fileutils' module UniverseCompiler module Entity module Persistence attr_accessor :source_uri def self.load(uri) entity = YAML.load_file uri entity.source_uri = uri entity end def save(uri = source_uri, save_options = { raise_error: true }) raise_error = save_options.fetch :raise_error, true valid? raise_error: raise_error FileUtils.mkpath File.dirname(uri) File.write uri, to_yaml, mode: 'w' self.source_uri = uri self end def delete universe.delete self unless self.source_uri.nil? FileUtils.rm self.source_uri end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
universe_compiler-0.3.8 | lib/universe_compiler/entity/persistence.rb |