module ConfigurationDsl
Constants
- VERSION
Public Instance Methods
configuration()
click to toggle source
# File lib/configuration_dsl.rb, line 47 def configuration @configuration_dsl ||= Impl.new(self) @configuration_dsl.find_configuration end
configure(&block)
click to toggle source
# File lib/configuration_dsl.rb, line 29 def configure(&block) @configuration_dsl ||= Impl.new(self) # Instance eval the block. if block_given? _module = @configuration_dsl.find_module raise Error, "cannot find configuration module" unless _module dsl = Dsl.new(Impl.dup_struct(configuration)) # Dup it to unfreeze it. dsl.send(:extend, _module) dsl.instance_eval(&block) @configuration_dsl.configuration = dsl.configuration.freeze end # Run the callback. callback = @configuration_dsl.find_callback instance_eval(&callback) if callback end
configure_with(configuration_module, &block)
click to toggle source
# File lib/configuration_dsl.rb, line 10 def configure_with(configuration_module, &block) @configuration_dsl ||= Impl.new(self) @configuration_dsl.module = configuration_module @configuration_dsl.callback = block if block_given? @configuration_dsl.default_configuration! # Automatically define setters. @configuration_dsl.module.module_eval do self::DEFAULTS.keys.each do |name| next if method_defined?(name) # Don't override custom setters. module_eval <<-code def #{name}(value) configuration.#{name} = value end code end end end