Class: Cero::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/cero/adapter.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  type: :memory
}
@@types =
[:memory, :sql, :key_value, :document].freeze
@@backends =
{
  memory: [],
  sql: [:sequel, :active_record],
  key_value: [],
  document: []
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Adapter

Returns a new instance of Adapter.



20
21
22
23
24
# File 'lib/cero/adapter.rb', line 20

def initialize(options = {})
  options = DEFAULT_OPTIONS.merge(options)
  configure_options(options)
  self
end

Instance Attribute Details

#backendObject (readonly)

Returns the value of attribute backend.



18
19
20
# File 'lib/cero/adapter.rb', line 18

def backend
  @backend
end

#proxyObject (readonly)

Returns the value of attribute proxy.



18
19
20
# File 'lib/cero/adapter.rb', line 18

def proxy
  @proxy
end

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/cero/adapter.rb', line 18

def type
  @type
end

Instance Method Details

#resolve_for(collection_name) ⇒ Object



26
27
28
29
30
# File 'lib/cero/adapter.rb', line 26

def resolve_for(collection_name)
  proxy_klass = get_backend_adapter
  @proxy = Cero::Adapters.qualified_const_get(proxy_klass).new(collection_name)
  self
end