Sha256: f69d8fc01f64edc1d0abde0836b29a90506a152963a3f979fd43398f7d30d288

Contents?: true

Size: 1020 Bytes

Versions: 68

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module Avm
  module Instances
    module Entries
      class EntryReader
        common_constructor :parent, :suffix, :options

        def auto_value
          parent.respond_to?(auto_value_method, true) ? parent.send(auto_value_method) : nil
        end

        def auto_value_method
          "auto_#{suffix.to_s.gsub('.', '_')}"
        end

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

        def optional_value
          read(required: false, noinput: true) || auto_value
        end

        def read(extra_options = {})
          ::Avm.configs.read_entry(full_path, options.merge(extra_options))
        end

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

        def value
          optional_value || read
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
avm-tools-0.69.3 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.69.2 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.69.1 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.69.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.68.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.67.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.66.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.65.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.64.2 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.64.1 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.64.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.63.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.62.4 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.62.3 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.62.2 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.62.1 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.62.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.61.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.60.0 lib/avm/instances/entries/entry_reader.rb
avm-tools-0.59.0 lib/avm/instances/entries/entry_reader.rb