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.
-
#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
64 65 66 67 68 |
# File 'lib/lotus/model/config/adapter.rb', line 64 def initialize(**) @type = [:type] @uri = [:uri] @class_name ||= Lotus::Utils::String.new("#{@type}_adapter").classify end |
Instance Attribute Details
#class_name ⇒ String (readonly)
Returns the adapter class name.
52 53 54 |
# File 'lib/lotus/model/config/adapter.rb', line 52 def class_name @class_name 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
79 80 81 82 |
# File 'lib/lotus/model/config/adapter.rb', line 79 def build(mapper) load_adapter instantiate_adapter(mapper) end |