Class: YamlSmith::SetKey
- Inherits:
-
FileCommand
- Object
- FileCommand
- YamlSmith::SetKey
- Defined in:
- lib/yaml_smith/set_key.rb
Overview
Sets a top-level key in a YAML file, adding or replacing it.
Instance Method Summary collapse
Methods inherited from FileCommand
Constructor Details
This class inherits a constructor from YamlSmith::FileCommand
Instance Method Details
#call ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/yaml_smith/set_key.rb', line 6 def call document = load_file(@path) value = load(@value) ensure_mapping(document) document[@key] = value write(Psych::Pure.dump(document)) end |