Class: KeyVortex::Adapter
- Inherits:
-
Object
- Object
- KeyVortex::Adapter
- Defined in:
- lib/key_vortex/adapter.rb,
lib/key_vortex/adapter/memory.rb
Overview
Adapters bridge the gap between the main logic of KeyVortex and individual backends. When using a backend, it can have various limitations on particular data types. KeyVortex will guarantee that these limitations are more permissive then the Records used to interact with it.
To keep dependencies down, the subclasses you’ll actually use will be implemented in other gems, but an in memory adapter does ship with this gem. Here are some that are available:
-
Stashify: File/blob storage
Building Adapters
For an adapter to work with KeyVortex, it needs to inherit from this class. In addition, it needs to override the following methods:
There is a separate gem, which provides a set of shared examples enforcing the correct behavior of those methods. PRs to include your gem in the list in the previous section will be accepted if they conform to that contract.
Direct Known Subclasses
Defined Under Namespace
Classes: Memory
Class Method Summary collapse
-
.symbol ⇒ Symbol
Provide the symbol used when using the factory method vortex.
Instance Method Summary collapse
-
#initialize ⇒ Adapter
constructor
A new instance of Adapter.
-
#limitation_for(field) ⇒ KeyVortex::Limitation
Get the limitation for the type of a given field.
-
#register_limitation(limitation) ⇒ Object
Apply the provided limitation to the adapter.
Constructor Details
#initialize ⇒ Adapter
Returns a new instance of Adapter.
32 33 34 |
# File 'lib/key_vortex/adapter.rb', line 32 def initialize @limitations = {} end |
Class Method Details
.symbol ⇒ Symbol
Provide the symbol used when using the factory method KeyVortex.vortex.
52 53 54 |
# File 'lib/key_vortex/adapter.rb', line 52 def self.symbol name.split(":").last.downcase.to_sym end |
Instance Method Details
#limitation_for(field) ⇒ KeyVortex::Limitation
Get the limitation for the type of a given field.
39 40 41 |
# File 'lib/key_vortex/adapter.rb', line 39 def limitation_for(field) @limitations[field.limitation.type] end |
#register_limitation(limitation) ⇒ Object
Apply the provided limitation to the adapter.
45 46 47 |
# File 'lib/key_vortex/adapter.rb', line 45 def register_limitation(limitation) @limitations[limitation.type] = limitation end |