Class: Pears::Provider::LocalFile

Inherits:
Base
  • Object
show all
Defined in:
lib/pears/provider/local_file.rb

Overview

Used for loading simple YAML file locally.

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#[], #each, #has_key?, #purge

Constructor Details

#initialize(file_path, on_failure: :raise) ⇒ LocalFile

Returns a new instance of LocalFile.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pears/provider/local_file.rb', line 8

def initialize(file_path,  on_failure: :raise)
  yaml_data = File.read(file_path)
  @data = parse_yaml(yaml_data)
rescue Errno::ENOENT,
    Pears::InvalidProviderData => error
  if on_failure == :null
    @data = {}
  else
    raise error
  end
end