Sha256: cab46780d0bf960082a3335fe9d101bd42ceff34533a47dfe783e941a20d1aa3
Contents?: true
Size: 1.08 KB
Versions: 34
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true require 'eac_ruby_utils/core_ext' module Avm module Entries class KeysConstantsSet common_constructor :entries_provider_class, :prefix, :suffixes # @return [Array<String>] def result if suffixes.is_a?(::Hash) keys_consts_set_from_hash elsif suffixes.is_a?(::Enumerable) keys_consts_set_from_enum else raise "Unmapped suffixes class: #{suffixes.class}" end end private # @return [String] def key_const_set(prefix, suffix) key = [prefix, suffix].compact_blank.join('.') entries_provider_class.const_set(key.gsub('.', '_').upcase, key) key end # @return [Array<String>] def keys_consts_set_from_enum suffixes.map { |suffix| key_const_set(prefix, suffix) } end # @return [Array<String>] def keys_consts_set_from_hash suffixes.flat_map do |k, v| self.class.new(entries_provider_class, prefix.to_s + (k.blank? ? '' : ".#{k}"), v).result end end end end end
Version data entries
34 entries across 34 versions & 2 rubygems