Module: R10K::Settings::Mixin::ClassMethods

Included in:
Git
Defined in:
lib/r10k/settings/mixin.rb

Instance Method Summary collapse

Instance Method Details

#def_setting_attr(key, default = nil) ⇒ void

This method returns an undefined value.

Define a setting and optional default on the extending class.

Parameters:

  • key (Symbol)
  • default (Object) (defaults to: nil)


24
25
26
27
# File 'lib/r10k/settings/mixin.rb', line 24

def def_setting_attr(key, default = nil)
  defaults.add_valid_key(key)
  defaults[key] = default if default
end

#defaultsR10K::Settings::Container

A singleton settings container for storing immutable default configuration on the extending class.



33
34
35
# File 'lib/r10k/settings/mixin.rb', line 33

def defaults
  @defaults ||= R10K::Settings::Container.new
end

#inherited(subclass) ⇒ void

This method returns an undefined value.

Allow subclasses to use the settings of the parent class as default values



48
49
50
51
52
# File 'lib/r10k/settings/mixin.rb', line 48

def inherited(subclass)
  subclass.instance_eval do
    @settings = R10K::Settings::Container.new(superclass.settings)
  end
end

#settingsR10K::Settings::Container

A singleton settings container for storing manual setting configurations on the extending class.



41
42
43
# File 'lib/r10k/settings/mixin.rb', line 41

def settings
  @settings ||= R10K::Settings::Container.new(defaults)
end