Sha256: 2e98192625f0a5b3511cd7339a16d2cd33183924783fc4b93d9a933337b95a28
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
# frozen_string_literal: true require 'avm/entries/uri_builder' require 'eac_config/entry_path' require 'eac_ruby_utils/core_ext' module Avm module Entries module Base class UriComponentEntryValue enable_method_class enable_listable lists.add_symbol :option, :default_value, :inherited_value_block common_constructor :entries_provider, :component_entry_path, :options, default: [{}] do self.component_entry_path = ::EacConfig::EntryPath.assert(component_entry_path) self.options = self.class.lists.option.hash_keys_validate!(options) end def default_value options[OPTION_DEFAULT_VALUE].call_if_proc end def inherited_result entries_provider.inherited_entry_value( id_entry_path.to_string, component_entry_path.to_string, &inherited_value_block ) end def inherited_value_block options[OPTION_INHERITED_VALUE_BLOCK] end # @return [EacConfig::EntryPath] def id_entry_path root_entry_path + %w[id] end # @return [String, nil] def result url_entry_value || inherited_result || default_value end # @return [EacConfig::EntryPath] def root_entry_path component_entry_path[0..-2] end # @return [Avm::Entries::Entry] def url_entry entries_provider.entry((root_entry_path + %w[url]).to_string) end def url_entry_value return unless url_entry.context_found? ::Avm::Entries::UriBuilder.from_source(url_entry.value.to_uri) .avm_field_get(component) end # @return [String] def component component_entry_path.last end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems