Sha256: 90c921a57847b6fcfe1d3ec8ed181cb58fb58d778bf763288a9c7b448f53daa4

Contents?: true

Size: 1003 Bytes

Versions: 17

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

require 'avm/entries/auto_values/entry'
require 'eac_config/node'
require 'eac_ruby_utils/core_ext'

module Avm
  module Entries
    class Entry
      common_constructor :parent, :suffix, :options

      def auto_value
        ::Avm::Entries::AutoValues::Entry.new(parent, suffix).value
      end

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

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

      def read
        context_entry.value
      end

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

      def value
        optional_value || read
      end

      def write(value)
        context_entry.value = value
      end

      private

      def context_entry
        ::EacConfig::Node.context.current.entry(full_path)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
avm-0.37.0 lib/avm/entries/entry.rb
eac_tools-0.24.0 sub/avm/lib/avm/entries/entry.rb
avm-0.36.0 lib/avm/entries/entry.rb
eac_tools-0.23.0 sub/avm/lib/avm/entries/entry.rb
avm-0.35.1 lib/avm/entries/entry.rb
eac_tools-0.22.0 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.21.0 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.20.0 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.19.0 sub/avm/lib/avm/entries/entry.rb
avm-0.35.0 lib/avm/entries/entry.rb
eac_tools-0.18.0 sub/avm/lib/avm/entries/entry.rb
avm-0.34.0 lib/avm/entries/entry.rb
eac_tools-0.17.0 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.16.1 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.16.0 sub/avm/lib/avm/entries/entry.rb
avm-0.33.0 lib/avm/entries/entry.rb
eac_tools-0.15.0 sub/avm/lib/avm/entries/entry.rb