Skip to content

stengland/sequel-mapper

Repository files navigation

Sequel::Mapper

A super simple datamapper built on top of Sequel. For creating repository like objects.

Installation

Add this line to your application's Gemfile:

gem 'sequel-mapper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequel-mapper

Usage

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 :)

Contributing

  1. Fork it ( https://github.com/stengland/sequel-mapper/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published