Class: Lotus::Model::Config::Adapter
- Inherits:
-
Object
- Object
- Lotus::Model::Config::Adapter
- Defined in:
- lib/lotus/model/config/adapter.rb
Overview
Configuration for the adapter
Lotus::Model has its own global configuration that can be manipulated via ‘Lotus::Model.configure`.
New adapter configuration can be registered via ‘Lotus::Model.adapter`.
By convention, Lotus inflects type to find the adapter class For example, if type is :sql, derived class will be ‘Lotus::Model::Adapters::SqlAdapter`
Instance Attribute Summary collapse
-
#class_name ⇒ String
readonly
The adapter class name.
-
#options ⇒ Hash
readonly
A list of non-mandatory options for the adapter.
-
#type ⇒ Symbol
readonly
The adapter name.
-
#uri ⇒ String
readonly
The adapter URI.
Instance Method Summary collapse
-
#build(mapper) ⇒ Lotus::Model::Adapters::SqlAdapter, Lotus::Model::Adapters::MemoryAdapter
Initialize the adapter.
-
#initialize(**options) ⇒ Lotus::Model::Config::Adapter
constructor
Initialize an adapter configuration instance.
Constructor Details
#initialize(**options) ⇒ Lotus::Model::Config::Adapter
Initialize an adapter configuration instance
68 69 70 71 72 73 74 75 76 |
# File 'lib/lotus/model/config/adapter.rb', line 68 def initialize(**) opts = .dup @type = opts.delete(:type) @uri = opts.delete(:uri) @options = opts @class_name ||= Lotus::Utils::String.new("#{@type}_adapter").classify end |
Instance Attribute Details
#class_name ⇒ String (readonly)
Returns the adapter class name.
56 57 58 |
# File 'lib/lotus/model/config/adapter.rb', line 56 def class_name @class_name end |
#options ⇒ Hash (readonly)
Returns a list of non-mandatory options for the adapter.
51 52 53 |
# File 'lib/lotus/model/config/adapter.rb', line 51 def @options end |
#type ⇒ Symbol (readonly)
Returns the adapter name.
42 43 44 |
# File 'lib/lotus/model/config/adapter.rb', line 42 def type @type end |
#uri ⇒ String (readonly)
Returns the adapter URI.
47 48 49 |
# File 'lib/lotus/model/config/adapter.rb', line 47 def uri @uri end |
Instance Method Details
#build(mapper) ⇒ Lotus::Model::Adapters::SqlAdapter, Lotus::Model::Adapters::MemoryAdapter
Initialize the adapter
87 88 89 90 |
# File 'lib/lotus/model/config/adapter.rb', line 87 def build(mapper) load_adapter instantiate_adapter(mapper) end |