Module: VagrantPlugins::ProxyConf::Config::KeyMixin::ClassMethods

Included in:
AptProxy, EnvProxy, GitProxy, Proxy, SvnProxy, YumProxy
Defined in:
lib/vagrant-proxyconf/config/key_mixin.rb

Overview

Methods for the including class to specify and access the configuration keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#keysArray<Key> (readonly)

Returns the configuration keys for the class.

Returns:

  • (Array<Key>)

    the configuration keys for the class



16
17
18
# File 'lib/vagrant-proxyconf/config/key_mixin.rb', line 16

def keys
  @keys ||= []
end

#nameObject

Defines a configuration key for the class. Creates ‘attr_accessor` for the key name and adds a VagrantPlugins::ProxyConf::Config::Key to #keys.

Parameters:

  • name (Symbol, String)

    the key name

  • opts (Hash)

    optional key properties



26
27
28
29
# File 'lib/vagrant-proxyconf/config/key_mixin.rb', line 26

def key(name, opts = {})
  self.class_eval { attr_accessor name }
  keys << Key.new(name, opts)
end

Instance Method Details

#key(name, opts = {}) ⇒ Object

Defines a configuration key for the class. Creates ‘attr_accessor` for the key name and adds a VagrantPlugins::ProxyConf::Config::Key to #keys.

Parameters:

  • name (Symbol, String)

    the key name

  • opts (Hash) (defaults to: {})

    optional key properties

Options Hash (opts):

  • :default (String, nil) — default: nil

    the default value

  • :env_var (String, nil) — default: nil

    the environment variable that overrides the configuration



26
27
28
29
# File 'lib/vagrant-proxyconf/config/key_mixin.rb', line 26

def key(name, opts = {})
  self.class_eval { attr_accessor name }
  keys << Key.new(name, opts)
end