Class: Exchange::Configurable
- Inherits:
-
Object
- Object
- Exchange::Configurable
- Extended by:
- SingleForwardable
- Includes:
- Singleton
- Defined in:
- lib/exchange/configurable.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#reset ⇒ Object
Reset the configuration to a set of defaults.
-
#set(hash) ⇒ Object
Set a configuration via a hash of options.
-
#subclass_with_constantize ⇒ NilClass, Class
(also: #subclass)
Alias method chain to instantiate the subclass from a symbol should it not be a class.
Instance Attribute Details
#subclass=(value) ⇒ Object
11 12 13 |
# File 'lib/exchange/configurable.rb', line 11 def subclass=(value) @subclass = value end |
Instance Method Details
#reset ⇒ Object
Reset the configuration to a set of defaults
38 39 40 |
# File 'lib/exchange/configurable.rb', line 38 def reset set Exchange::Configuration::DEFAULTS[key] end |
#set(hash) ⇒ Object
Set a configuration via a hash of options
28 29 30 31 32 33 34 |
# File 'lib/exchange/configurable.rb', line 28 def set hash hash.each_pair do |k,v| self.send(:"#{k}=", v) end self end |
#subclass_with_constantize ⇒ NilClass, Class Also known as: subclass
Alias method chain to instantiate the subclass from a symbol should it not be a class
18 19 20 21 |
# File 'lib/exchange/configurable.rb', line 18 def subclass_with_constantize self.subclass = parent_module.const_get camelize(self.subclass_without_constantize) unless !self.subclass_without_constantize || self.subclass_without_constantize.is_a?(Class) subclass_without_constantize end |