Skip to content

Repository files navigation

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)classAsset < Sequel::Modelmany_to_one:attachable,:polymorphic=>trueendclassNote < Sequel::Modelone_to_many:assets,:as=>:attachableendclassPost < Sequel::Modelone_to_many:assets,:as=>:attachableend

Schema

Include the polymorphic columns in your DB schema:

Sequel.migrationdochangedocreate_table:assetsdo# ...Integer:attachable_idString:attachable_type# ...index[:attachable_id,:attachable_type]endendend

More usage examples

See specs.

Important note

See here.

Feedback and contribute

https://github.com/jackdempsey/sequel_polymorphic

License

MIT

About

No description, website, or topics provided.

Resources

Stars

36 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages