Class: Axiom::Adapter::Memory
- Inherits:
-
Object
- Object
- Axiom::Adapter::Memory
- Includes:
- Adamantium::Flat
- Defined in:
- lib/axiom/adapter/memory.rb,
lib/axiom/adapter/memory/version.rb
Overview
A reference adapter for in-memory information
Constant Summary collapse
- UnknownRelationError =
Raised when the relation name is unknown
Class.new(IndexError)
- VERSION =
Gem version
'0.2.0'.freeze
Instance Method Summary collapse
-
#[](name) ⇒ Axiom::Relation
Get relation variable in the schema.
-
#[]=(name, relation) ⇒ undefined
Set the relation variable in the schema.
-
#initialize(schema = {}) ⇒ undefined
constructor
Initialize a Memory adapter.
Constructor Details
#initialize(schema = {}) ⇒ undefined
Initialize a Memory adapter
42 43 44 45 |
# File 'lib/axiom/adapter/memory.rb', line 42 def initialize(schema = {}) @schema = ThreadSafe::Hash.new schema.each { |name, relation| self[name] = relation } end |
Instance Method Details
#[](name) ⇒ Axiom::Relation
Get relation variable in the schema
57 58 59 60 61 |
# File 'lib/axiom/adapter/memory.rb', line 57 def [](name) schema.fetch(name) do fail UnknownRelationError, "the relation named #{name} is unknown" end end |