Sha256: 23ecdf79e4f343ae887d1fa3bcb4dacc0b4fb78f466554cc7b33ca5a2d736217

Contents?: true

Size: 1.15 KB

Versions: 44

Compression:

Stored size: 1.15 KB

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
        auto_value_entry.value
      end

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

      # @return [Boolean]
      def context_found?
        context_entry.found?
      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

44 entries across 44 versions & 2 rubygems

Version Path
eac_tools-0.41.0 sub/avm/lib/avm/entries/entry.rb
avm-0.54.0 lib/avm/entries/entry.rb
eac_tools-0.40.0 sub/avm/lib/avm/entries/entry.rb
avm-0.53.0 lib/avm/entries/entry.rb
eac_tools-0.39.0 sub/avm/lib/avm/entries/entry.rb
avm-0.52.0 lib/avm/entries/entry.rb
eac_tools-0.38.0 sub/avm/lib/avm/entries/entry.rb
avm-0.51.0 lib/avm/entries/entry.rb
eac_tools-0.37.2 sub/avm/lib/avm/entries/entry.rb
avm-0.50.0 lib/avm/entries/entry.rb
eac_tools-0.37.1 sub/avm/lib/avm/entries/entry.rb
avm-0.49.0 lib/avm/entries/entry.rb
eac_tools-0.37.0 sub/avm/lib/avm/entries/entry.rb
avm-0.48.0 lib/avm/entries/entry.rb
eac_tools-0.36.1 sub/avm/lib/avm/entries/entry.rb
avm-0.47.0 lib/avm/entries/entry.rb
eac_tools-0.36.0 sub/avm/lib/avm/entries/entry.rb
avm-0.46.0 lib/avm/entries/entry.rb
eac_tools-0.35.0 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.34.0 sub/avm/lib/avm/entries/entry.rb