Class: Exchange::Configurable

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Includes:
Singleton
Defined in:
lib/exchange/configurable.rb

Overview

Since:

  • 0.1

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#subclass=(value) ⇒ Object

Since:

  • 0.1


11
12
13
# File 'lib/exchange/configurable.rb', line 11

def subclass=(value)
  @subclass = value
end

Instance Method Details

#resetObject

Reset the configuration to a set of defaults

Since:

  • 0.1


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

Since:

  • 0.1


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_constantizeNilClass, Class Also known as: subclass

Alias method chain to instantiate the subclass from a symbol should it not be a class

Returns:

  • (NilClass, Class)

    The subclass or nil

Since:

  • 0.1


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