Active::Record's ugly brother, who was locked in the basement... until now! This gem is a dead simple implementation of AR with file persistent storage.
Add this line to your application's Gemfile:
gem 'rekord'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rekord
# Configuration:
Rekord::Base.configure do |c|
c.storage = Rekord::PersistentStorage.new(path: 'your.db')
end
# Model definition:
class Book < Rekord::Base
prop :id
prop :title
prop :author
end
# Create:
book = Book.create(title: "A Sound of Thunder", author: "Ray Bradburry")
# Init:
book = Book.new(title: "A Sound of Thunder", author: "Ray Bradburry")
book.new_record?
# Props
book.props = { author: "me" }
book.props # { title: "A Sound of Thunder", author: "me" }
book.save
# Read:
Book.find(1)
Book.where author: 'me'
# Update:
book.update author: 'me'
# Delete:
book.destroy
The gem is available as open source under the terms of the MIT License.