Class: CodeUnion::Config::FileAdapter
- Inherits:
-
Object
- Object
- CodeUnion::Config::FileAdapter
- Defined in:
- lib/codeunion/config.rb
Overview
Reads and writes YAML to the FileSystem
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ FileAdapter
constructor
A new instance of FileAdapter.
- #to_hash ⇒ Object (also: #to_h)
- #write(data) ⇒ Object
Constructor Details
#initialize(file_path) ⇒ FileAdapter
Returns a new instance of FileAdapter.
81 82 83 |
# File 'lib/codeunion/config.rb', line 81 def initialize(file_path) @file_path = file_path end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
79 80 81 |
# File 'lib/codeunion/config.rb', line 79 def file_path @file_path end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
90 91 92 93 |
# File 'lib/codeunion/config.rb', line 90 def to_hash ensure_exists! YAML.load_file(file_path).dup end |
#write(data) ⇒ Object
85 86 87 88 |
# File 'lib/codeunion/config.rb', line 85 def write(data) ensure_exists! write_fearlessly(data) end |