Sha256: f15885df60cf63eea0b708631f23e4ec9e2888c9f341fcff54fe28abd4b8f894

Contents?: true

Size: 1.26 KB

Versions: 121

Compression:

Stored size: 1.26 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 value!
        optional_value.if_present { |v| return v }
        context_entry.value!
      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

121 entries across 121 versions & 2 rubygems

Version Path
eac_tools-0.86.8 sub/avm/lib/avm/entries/entry.rb
avm-0.86.2 lib/avm/entries/entry.rb
eac_tools-0.86.7 sub/avm/lib/avm/entries/entry.rb
avm-0.86.1 lib/avm/entries/entry.rb
eac_tools-0.86.5 sub/avm/lib/avm/entries/entry.rb
avm-0.86.0 lib/avm/entries/entry.rb
eac_tools-0.86.4 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.86.3 sub/avm/lib/avm/entries/entry.rb
avm-0.85.0 lib/avm/entries/entry.rb
eac_tools-0.86.2 sub/avm/lib/avm/entries/entry.rb
avm-0.84.3 lib/avm/entries/entry.rb
eac_tools-0.86.1 sub/avm/lib/avm/entries/entry.rb
eac_tools-0.84.2 sub/avm/lib/avm/entries/entry.rb
avm-0.84.2 lib/avm/entries/entry.rb
eac_tools-0.84.1 sub/avm/lib/avm/entries/entry.rb
avm-0.84.1 lib/avm/entries/entry.rb
eac_tools-0.84.0 sub/avm/lib/avm/entries/entry.rb
avm-0.84.0 lib/avm/entries/entry.rb
eac_tools-0.83.0 sub/avm/lib/avm/entries/entry.rb
avm-0.83.0 lib/avm/entries/entry.rb