class Streetlib::Vault::Loader
Attributes
content[RW]
path[RW]
Public Class Methods
load(path:)
click to toggle source
# File lib/streetlib/vault/loader.rb, line 16 def self.load(path:) instance = new(path: path) result = instance.load return result if result.error? Result.success(instance) end
new(path:)
click to toggle source
# File lib/streetlib/vault/loader.rb, line 11 def initialize(path:) self.path = path self.content = nil end
Public Instance Methods
load()
click to toggle source
# File lib/streetlib/vault/loader.rb, line 24 def load context = { path: path } return Result.error(context).code!(:no_such_file) unless File.exists?(path) begin yaml_content = YAML.load_file(path) rescue StandardError => error return Result. error(context.merge({ error: error })). code!(:cant_load_file) end self.content = Content.new(yaml_content) Result.success end