Sha256: f42d31d5fc5a78e058d36fcb9f106880e20fa4c4921ef88914b6b6b168516c0a

Contents?: true

Size: 1.54 KB

Versions: 16

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Avm
  module Instances
    module EntryKeys
      class << self
        def all
          all_keys.to_a
        end

        def keys_consts_set(prefix, suffixes)
          if suffixes.is_a?(::Hash)
            keys_consts_set_from_hash(prefix, suffixes)
          elsif suffixes.is_a?(::Enumerable)
            keys_consts_set_from_enum(prefix, suffixes)
          else
            raise "Unmapped suffixes class: #{suffixes.class}"
          end
        end

        def key_const_set(prefix, suffix)
          key = [prefix, suffix].reject(&:blank?).join('.')
          const_set(key.gsub('.', '_').upcase, key)
          all_keys << key
        end

        private

        def all_keys
          @all_keys ||= ::Set.new
        end

        def keys_consts_set_from_enum(prefix, suffixes)
          suffixes.each { |suffix| key_const_set(prefix, suffix) }
        end

        def keys_consts_set_from_hash(prefix, suffixes)
          suffixes.each { |k, v| keys_consts_set(prefix.to_s + (k.blank? ? '' : ".#{k}"), v) }
        end
      end

      {
        '' => %w[fs_path host_id source_instance_id],
        database: %w[id hostname name password port system username],
        mailer: {
          '' => %w[id from reply_to],
          smtp: %w[address port domain username password authentication starttls_auto]
        },
        ssh: %w[hostname port url username],
        web: %w[authority hostname path port scheme url userinfo]
      }.each { |prefix, suffixes| keys_consts_set(prefix, suffixes) }
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
avm-tools-0.84.0 lib/avm/instances/entry_keys.rb
avm-tools-0.83.0 lib/avm/instances/entry_keys.rb
avm-tools-0.82.1 lib/avm/instances/entry_keys.rb
avm-tools-0.82.0 lib/avm/instances/entry_keys.rb
avm-tools-0.81.0 lib/avm/instances/entry_keys.rb
avm-tools-0.80.0 lib/avm/instances/entry_keys.rb
avm-tools-0.79.0 lib/avm/instances/entry_keys.rb
avm-tools-0.78.0 lib/avm/instances/entry_keys.rb
avm-tools-0.77.0 lib/avm/instances/entry_keys.rb
avm-tools-0.76.1 lib/avm/instances/entry_keys.rb
avm-tools-0.76.0 lib/avm/instances/entry_keys.rb
avm-tools-0.75.1 lib/avm/instances/entry_keys.rb
avm-tools-0.75.0 lib/avm/instances/entry_keys.rb
avm-tools-0.74.1 lib/avm/instances/entry_keys.rb
avm-tools-0.74.0 lib/avm/instances/entry_keys.rb
avm-tools-0.73.0 lib/avm/instances/entry_keys.rb