No commit activity in last 3 years
No release in over 3 years
Use Axiom relations with an in-memory datastore
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.5.2, ~> 1.5

Runtime

~> 0.2.0
>= 0.3.1, ~> 0.3
 Project Readme

axiom-memory-adapter

Use Axiom relations with an in-memory datastore

Gem Version Build Status Dependency Status Code Climate Coverage Status

Examples

require 'axiom-memory-adapter'

adapter = Axiom::Adapter::Memory.new(
  customers: Axiom::Relation.new([[:id, Integer], [:name, String]]),
  orders:    Axiom::Relation.new([[:id, Integer], [:customer_id, Integer]])
)

# Insert customer data
customers = adapter[:customers]
customers.insert([[1, 'Dan Kubb']])
customers.insert([[2, 'John Doe']])

# Insert order data
orders = adapter[:orders]
orders.insert([[1, 1]])
orders.insert([[2, 1]])
orders.insert([[3, 1]])
orders.insert([[4, 2]])

# Join customers and orders
customer_orders = customers.
  rename(id: :customer_id).
  join(orders.rename(id: :order_id))

# Demonstrate writable view-like behaviour

# Insert into the join
customer_orders.insert([[3, 'Jane Doe', 5]])

# Inserts are propagated to the base relations
customers.count  # => 3
orders.count     # => 5

# Delete from a join
customer_orders.delete([[3, 'Jane Doe', 5]])

# Deletes are propagated to the base relations
customers.count  # => 2
orders.count     # => 4

Contributing

See CONTRIBUTING.md for details.

Copyright

Copyright © 2013 Dan Kubb. See LICENSE for details.