Class: Ensconce::YamlFileAdapter
- Inherits:
-
Adapter
- Object
- Adapter
- Ensconce::YamlFileAdapter
show all
- Defined in:
- lib/ensconce/adapters/yaml_file_adapter.rb
Instance Attribute Summary
Attributes inherited from Adapter
#params, #settings
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Adapter
config, for, #initialize, options, #options, options=
Class Method Details
.all ⇒ Object
4
5
6
|
# File 'lib/ensconce/adapters/yaml_file_adapter.rb', line 4
def self.all
YAML.load_file options[:file]
end
|
Instance Method Details
#get ⇒ Object
8
9
10
11
12
|
# File 'lib/ensconce/adapters/yaml_file_adapter.rb', line 8
def get
raise "No file defined" unless options[:file]
data = YAML.load_file options[:file]
data[settings.id]
end
|
#push(data) ⇒ Object
14
15
16
17
|
# File 'lib/ensconce/adapters/yaml_file_adapter.rb', line 14
def push(data)
result = Mangle.deep_merge self.class.all, {settings.id => data}
File.open(options[:file], 'w+') {|f| f.write(result.to_yaml) }
end
|