Class: Avm::Entries::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/entries/entry.rb,
lib/avm/entries/entry/no_context_entry.rb

Defined Under Namespace

Classes: NoContextEntry

Instance Method Summary collapse

Instance Method Details

#auto_valueObject



12
13
14
# File 'lib/avm/entries/entry.rb', line 12

def auto_value
  auto_value_entry.value
end

#auto_value_entryObject



16
17
18
# File 'lib/avm/entries/entry.rb', line 16

def auto_value_entry
  @auto_value_entry ||= ::Avm::Entries::AutoValues::Entry.new(parent, suffix)
end

#context_found?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/avm/entries/entry.rb', line 21

def context_found?
  context_entry.found?
end

#found?Boolean

Returns:

  • (Boolean)


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

def found?
  context_found?
end

#full_pathObject



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

def full_path
  (parent.path_prefix + suffix_as_array).join('.')
end

#optional_valueObject



34
35
36
# File 'lib/avm/entries/entry.rb', line 34

def optional_value
  context_entry.found? ? context_entry.value : auto_value
end

#readObject



38
39
40
# File 'lib/avm/entries/entry.rb', line 38

def read
  context_entry.value
end

#suffix_as_arrayObject



42
43
44
45
46
47
48
# File 'lib/avm/entries/entry.rb', line 42

def suffix_as_array
  if suffix.is_a?(::Array)
    suffix.dup
  else
    ::EacConfig::PathsHash.parse_entry_key(suffix.to_s)
  end
end

#valueObject



50
51
52
# File 'lib/avm/entries/entry.rb', line 50

def value
  optional_value || read
end

#value!Object



54
55
56
57
# File 'lib/avm/entries/entry.rb', line 54

def value!
  optional_value.if_present { |v| return v }
  context_entry.value!
end

#write(value) ⇒ Object



59
60
61
# File 'lib/avm/entries/entry.rb', line 59

def write(value)
  context_entry.value = value
end