Class: Omnidata::Adapters::AdapterManager
- Inherits:
-
Object
- Object
- Omnidata::Adapters::AdapterManager
- Includes:
- Singleton
- Defined in:
- lib/omnidata/adapters/adapter_manager.rb
Instance Attribute Summary collapse
-
#adapters ⇒ Object
readonly
Returns the value of attribute adapters.
Instance Method Summary collapse
- #adapter(name) ⇒ Object
- #add(name, options) ⇒ Object
- #build_adapter(options) ⇒ Object
-
#initialize ⇒ AdapterManager
constructor
A new instance of AdapterManager.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ AdapterManager
Returns a new instance of AdapterManager.
14 15 16 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 14 def initialize reset end |
Instance Attribute Details
#adapters ⇒ Object (readonly)
Returns the value of attribute adapters.
12 13 14 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 12 def adapters @adapters end |
Instance Method Details
#adapter(name) ⇒ Object
38 39 40 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 38 def adapter(name) @adapters[name] end |
#add(name, options) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 22 def add(name, ) if adapter(name) raise AdapterError.new("adapter #{name} exists") end adapter = build_adapter() adapter.name = name @adapters[name] = adapter end |
#build_adapter(options) ⇒ Object
32 33 34 35 36 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 32 def build_adapter() opts = .dup name = opts.delete(:adapter).capitalize "Omnidata::Adapters::#{name}Adapter".constantize.new(opts) end |
#reset ⇒ Object
18 19 20 |
# File 'lib/omnidata/adapters/adapter_manager.rb', line 18 def reset @adapters = {} end |