Method: ConfigurationBlocks#configuration_block

Defined in:
lib/configuration-blocks/core.rb,
lib/configuration-blocks/core.rb

#configuration_block(base = self, &block) ⇒ Module, Object

Returns configuration module that delegates methods pointing to the given base object and optionally evaluates the given block in the context of this module or in the current context.

If a block is given then it is evaluated in the context of the configuration module. If a block with at least one argument is given then the context remains as it was but the first argument is the module.

Examples:

# using external access to configuration module:
x.configuration_block do |c|
  c.some_setting  :a
  c.other_setting :b
end

# using internal access to configuration module:
x.configuration_block do
  some_setting  :a
  other_setting :b
end

Parameters:

  • (defaults to: self)

    base object which delegators will point to (defaults to object on which this method has been called). If symbol is given, then it should contain the name of a method that will be called on current object.

Returns:

  • configuration module if not block is given or a block takes no arguments. In case of one or more arguments in a block it also returns a module unless break statement is used; in such case the value passed to break is returned.



25
26
27
# File 'lib/configuration-blocks/core.rb', line 25

def configuration_block(base = self, &block)
  self.class.configuration_block(base, &block)
end