No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A gem that provides Sequel::Models with polymorphic association capabilities
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 5.8
~> 11.3
~> 0.10
~> 1.3

Runtime

< 6, >= 4.0.0
 Project Readme

Sequel Polymorphic (unmaintained)

A plugin for Sequel that lets you easily create polymorphic associations.

Required:

  • Sequel >= 4.0.0 and Ruby >= 1.8.7,
  • or Sequel >= 5.0.0 and Ruby >= 1.9.2.

(Note: Ruby 1.8.7 option is not tested.)

Usage examples

Models

Sequel::Model.plugin(:polymorphic)

class Asset < Sequel::Model
  many_to_one :attachable, :polymorphic => true
end

class Note < Sequel::Model
  one_to_many :assets, :as => :attachable
end

class Post < Sequel::Model
  one_to_many :assets, :as => :attachable
end

Schema

Include the polymorphic columns in your DB schema:

Sequel.migration do
  change do
    create_table :assets do
      # ...
      Integer :attachable_id
      String :attachable_type
      # ...
      index [:attachable_id, :attachable_type]
    end
  end
end

More usage examples

See specs.

Important note

See here.

Feedback and contribute

https://github.com/jackdempsey/sequel_polymorphic

License

MIT