Sha256: 6cf7031988ef4901eb6e8d850cc06fb9ead194c802a25fe721bbc7f4af0181a1
Contents?: true
Size: 848 Bytes
Versions: 2
Compression:
Stored size: 848 Bytes
Contents
# frozen_string_literal: true require 'hanami/interactor' require 'json' module Umwelt::Abstract::File class Restore include Hanami::Interactor expose :struct def initialize(path: '.umwelt', mapper: Struct) @path = path @mapper = mapper end private def read(path) path.read rescue Errno::ENOENT error! "Failed reading #{path}" end def parse(str) JSON.parse(str, symbolize_names: true) rescue JSON::ParserError error! "Failed JSON parsing #{self.class.name}" end def struct(struct_hash) clean @mapper.new.call(struct_hash) end def clean(result) if result.success? result.struct else error! result.errors end end def umwelt_root_path Pathname.pwd / @path end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
umwelt-0.1.1 | lib/umwelt/abstract/file/restore.rb |
umwelt-0.1.0 | lib/umwelt/abstract/file/restore.rb |