Class: YAMLObjectMapper
- Inherits:
-
Object
- Object
- YAMLObjectMapper
- Defined in:
- lib/less_active_record/yaml_object_mapper.rb
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
Instance Method Summary collapse
- #dump_file(object) ⇒ Object
-
#initialize(file_name) ⇒ YAMLObjectMapper
constructor
A new instance of YAMLObjectMapper.
- #load_file ⇒ Object
Constructor Details
#initialize(file_name) ⇒ YAMLObjectMapper
6 7 8 |
# File 'lib/less_active_record/yaml_object_mapper.rb', line 6 def initialize(file_name) @file_name = file_name end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/less_active_record/yaml_object_mapper.rb', line 4 def file_name @file_name end |
Instance Method Details
#dump_file(object) ⇒ Object
14 15 16 17 18 |
# File 'lib/less_active_record/yaml_object_mapper.rb', line 14 def dump_file(object) File.open(file_name, 'w') do |file| YAML.dump(object, file) end end |
#load_file ⇒ Object
10 11 12 |
# File 'lib/less_active_record/yaml_object_mapper.rb', line 10 def load_file YAML.load_file(file_name) if File.exists?(file_name) end |