Module: ConfigurationBlocks

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

Overview

Author

Paweł Wilk ([email protected])

Copyright

© 2012 by Paweł Wilk

License

This program is licensed under the terms of GNU Lesser General Public License or Ruby License.

This file contains version information.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#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


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

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