Module: Axiom::Adapter
- Included in:
- DataObjects, Memory
- Defined in:
- lib/rom/support/axiom/adapter.rb,
lib/rom/support/axiom/adapter/memory.rb,
lib/rom/support/axiom/adapter/sqlite3.rb,
lib/rom/support/axiom/adapter/postgres.rb,
lib/rom/support/axiom/adapter/data_objects.rb
Overview
think about making this a (base) class
Provides base functionality for every axiom adapter
Defined Under Namespace
Classes: DataObjects, Memory, Postgres, Sqlite3
Constant Summary collapse
- REGISTRY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The registry of adapters
{}
Class Method Summary collapse
-
.build(uri) ⇒ Object
private
Return the adapter to use for the given
uri
. -
.get(uri) ⇒ Class
private
Return the adapter class registered for
uri
.
Instance Method Summary collapse
-
#uri_scheme(name) ⇒ self
Set the uri scheme for an adapter class.
Class Method Details
.build(uri) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the adapter to use for the given uri
41 42 43 44 45 46 47 48 49 |
# File 'lib/rom/support/axiom/adapter.rb', line 41 def self.build(uri) klass = get(uri) if klass.name == 'Axiom::Adapter::Memory' klass.new else klass.new(uri) end end |
.get(uri) ⇒ Class
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the adapter class registered for uri
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/rom/support/axiom/adapter.rb', line 63 def self.get(uri) uri_scheme = uri.scheme REGISTRY.fetch(uri_scheme) { raise( UnknownAdapterError, "#{uri_scheme.inspect} is no registered uri scheme" ) } end |
Instance Method Details
#uri_scheme(name) ⇒ self
Set the uri scheme for an adapter class
95 96 97 |
# File 'lib/rom/support/axiom/adapter.rb', line 95 def uri_scheme(name) REGISTRY[name.to_s] = self end |