Class: EacConfig::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_config/entry.rb,
lib/eac_config/entry/not_found_error.rb

Defined Under Namespace

Classes: NotFoundError

Instance Method Summary collapse

Instance Method Details

#found?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/eac_config/entry.rb', line 14

def found?
  node_entry.if_present(false, &:found?)
end

#found_nodeObject



18
19
20
# File 'lib/eac_config/entry.rb', line 18

def found_node
  node_entry.if_present(&:node)
end

#secret_valueObject



22
23
24
# File 'lib/eac_config/entry.rb', line 22

def secret_value
  node_entry.if_present(&:secret_value)
end

#to_sObject



26
27
28
# File 'lib/eac_config/entry.rb', line 26

def to_s
  "#{self.class}[RootNode: #{root_node}, Path: #{path}]"
end

#valueObject



30
31
32
# File 'lib/eac_config/entry.rb', line 30

def value
  node_entry.if_present(&:value)
end

#value!Object



34
35
36
37
38
# File 'lib/eac_config/entry.rb', line 34

def value!
  return value if found?

  raise ::EacConfig::Entry::NotFoundError, self
end

#value=(a_value) ⇒ Object



40
41
42
# File 'lib/eac_config/entry.rb', line 40

def value=(a_value)
  write_node.self_entry(path).value = a_value
end

#write_nodeObject



44
45
46
# File 'lib/eac_config/entry.rb', line 44

def write_node
  root_node.write_node || root_node
end