Class: EacConfig::YamlFileNode

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/eac_config/yaml_file_node.rb,
lib/eac_config/yaml_file_node/entry.rb,
lib/eac_config/yaml_file_node/self_entries.rb

Defined Under Namespace

Classes: Entry, SelfEntries

Instance Attribute Summary

Attributes included from Node

#write_node

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Node

context, #entries, #entry, #load_path, #recursive_loaded_nodes, #self_entry, #self_entry_class, #self_loaded_nodes, #with_prefix

Class Method Details

.from_uri(uri) ⇒ Object



15
16
17
# File 'lib/eac_config/yaml_file_node.rb', line 15

def from_uri(uri)
  return new(uri.to_addressable.path) if uri.to_addressable.scheme == 'file'
end

Instance Method Details

#persist_data(new_data) ⇒ Object



25
26
27
28
29
# File 'lib/eac_config/yaml_file_node.rb', line 25

def persist_data(new_data)
  path.parent.mkpath
  ::EacRubyUtils::Yaml.dump_file(path, new_data)
  reset_cache(:data)
end

#to_sObject



35
36
37
# File 'lib/eac_config/yaml_file_node.rb', line 35

def to_s
  "#{self.class}[#{path}]"
end

#urlObject



31
32
33
# File 'lib/eac_config/yaml_file_node.rb', line 31

def url
  ::Addressable::URI.parse("file://#{path.expand_path}")
end