lib/tap/support/configurable.rb in bahuvrihi-tap-0.10.7 vs lib/tap/support/configurable.rb in bahuvrihi-tap-0.10.8
- old
+ new
@@ -19,11 +19,11 @@
#
# c = ConfigClass.new
# c.config.class # => InstanceConfiguration
# c.config # => {:one => 'one', :two => 'two', :three => 'three'}
#
- # The <tt>config</tt> object acts as a kind of forwarding hash; declared configurations
+ # The <tt>config</tt> object acts as a forwarding hash; declared configurations
# map to accessors while undeclared configurations are stored internally:
#
# c.config[:one] = 'ONE'
# c.one # => 'ONE'
#
@@ -31,12 +31,12 @@
# c.config # => {:one => 1, :two => 'two', :three => 'three'}
#
# c.config[:undeclared] = 'value'
# c.config.store # => {:undeclared => 'value'}
#
- # The writer method for a configuration can be modified by providing a block to config.
- # The Validation module provides a number of common validation and string-transform
+ # The writer for a configuration can be defined by providing a block to config.
+ # The Validation module provides a number of common validation/transform
# blocks which can be accessed through the class method 'c':
#
# class SubClass < ConfigClass
# config(:one, 'one') {|v| v.upcase }
# config :two, 2, &c.integer
@@ -53,25 +53,25 @@
# s.two = "3"
# s.two # => 3
# s.two = nil # !> ValidationError
# s.two = 'str' # !> ValidationError
#
- # As shown above, configurations are inherited from the parent and can be
+ # As shown above, configurations are inherited from the parent and may be
# overridden in subclasses. See ConfigurableClass for more details.
#
module Configurable
# Extends including classes with ConfigurableClass
- def self.included(mod)
+ def self.included(mod) # :nodoc:
mod.extend Support::ConfigurableClass if mod.kind_of?(Class)
end
- # The instance configurations for self
+ # An InstanceConfiguration with configurations for self
attr_reader :config
- # Reconfigures self with the given configuration overrides. Only
- # the specified configs are modified. Override keys are symbolized.
+ # Reconfigures self with the given overrides. Only the specified configs
+ # are modified. Keys are symbolized.
#
# Returns self.
def reconfigure(overrides={})
keys = (config.class_config.ordered_keys + overrides.keys) & overrides.keys
keys.each do |key|
@@ -79,22 +79,21 @@
end
self
end
- # Reinitializes config with a copy of orig.config (this assures
- # that duplicates have their own copy of configurations,
- # separate from the original object).
+ # Reinitializes configurations in the copy such that
+ # the new object has it's own set of configurations,
+ # separate from the original object.
def initialize_copy(orig)
super
initialize_config(orig.config)
end
protected
- # Initializes config to an InstanceConfiguration specific for self.
- # Default config values are assigned or overridden if specified in
- # overrides. Override keys are symbolized.
+ # Initializes config to an InstanceConfiguration. Default config values
+ # are overridden as specified by overrides. Keys are symbolized.
def initialize_config(overrides={})
class_config = self.class.configurations
@config = class_config.instance_config
overrides.each_pair do |key, value|
\ No newline at end of file