Module: Configurable::ConfigAccessors

Defined in:
lib/configurable.rb

Overview

Methods to access the class’ current configuration and default configuration.

Instance Method Summary collapse

Instance Method Details

#configObject

Returns the class’ configuration object. This object is an instance of the class’ Config struct (which is a ConfigStruct::Struct created by the Macros.configurable_options method). It is lazily created the first time the method is called as a copy of the default configuration object.

Raises:

  • (NameError)


141
142
143
144
145
# File 'lib/configurable.rb', line 141

def config
  raise NameError, 'use configurable_options to define settings' unless
    config_struct
  @_config ||= config_struct.defaults.dup # dup unfreezes
end

#default_configObject

:nodoc:

Raises:

  • (NameError)


147
148
149
150
151
# File 'lib/configurable.rb', line 147

def default_config #:nodoc:
  raise NameError, 'use configurable_options to define settings' unless
    config_struct
  config_struct.defaults
end