A super simple datamapper built on top of Sequel. For creating repository like objects.
Add this line to your application's Gemfile:
gem 'sequel-mapper'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sequel-mapper
require 'sequel/mapper'
class Account
def initialize(attrs={})
#some way to covert attrs to @attibutes
end
end
class Accounts
include Sequel::Mapper
dataset :accounts
end
DB = Sequel.connect
accounts = Accounts.new(DB)
accounts.all #=> all accounts
# CRUD
account = Account.new(email: '[email protected]')
accounts.create(account)
accounts.find(1)
accounts.update(account)
accounts.delete(account)
TODO: Improve usage instructions :)
- Fork it ( https://github.com/stengland/sequel-mapper/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request