Class: Ez::Settings::Backend::FileSystem
- Inherits:
-
Object
- Object
- Ez::Settings::Backend::FileSystem
- Defined in:
- lib/ez/settings/backend/file_system.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file) ⇒ FileSystem
constructor
A new instance of FileSystem.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(file) ⇒ FileSystem
Returns a new instance of FileSystem.
11 12 13 |
# File 'lib/ez/settings/backend/file_system.rb', line 11 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/ez/settings/backend/file_system.rb', line 9 def file @file end |
Instance Method Details
#read ⇒ Object
15 16 17 18 19 |
# File 'lib/ez/settings/backend/file_system.rb', line 15 def read return {} unless File.exist?(file) YAML.load_file(file).deep_symbolize_keys end |
#write(data) ⇒ Object
21 22 23 |
# File 'lib/ez/settings/backend/file_system.rb', line 21 def write(data) File.write(file, read.merge(data).deep_stringify_keys.to_yaml) end |