Sha256: 68e6f41cc133e540330820dcd204578044ecd68ceae0a5305b0c28ff303be889

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'rubygems'
require 'sinatra'
require 'classy_resources/sequel'
require 'sequel'

Sequel::Model.db = Sequel.sqlite

Sequel::Model.db.instance_eval do
  create_table! :users do
    primary_key :id
    varchar :name
  end

  create_table! :subscriptions do
    primary_key :id
    int :user_id
    varchar :name
  end
end

class User < Sequel::Model(:users)
  one_to_many :subscriptions
end

class Subscription < Sequel::Model(:subscriptions)
  many_to_one :users
end

define_resource :users, :collection => [:get, :post],
                        :member     => [:put, :delete, :get]

define_resource :subscriptions, :collection => [:get, :post],
                                :parent     => :users

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
giraffesoft-classy_resources-0.1.0 test/fixtures/sequel_test_app.rb