Module: Resort::Sortable
- Defined in:
- lib/resort.rb
Overview
TODO:
Refactor into a more OO solution, maybe implementing a LinkedList object.
The module encapsulating all the Resort functionality.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
When included, extends the includer with ClassMethods, and includes InstanceMethods in it.
Class Method Details
.included(base) ⇒ Object
When included, extends the includer with ClassMethods, and includes InstanceMethods in it.
It also establishes the required relationships. It is necessary that the includer table has the following database columns:
t.references :next
t.boolean :first
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/resort.rb', line 59 def included(base) base.extend ClassMethods base.send :include, InstanceMethods base.has_one :previous, :class_name => base.name, :foreign_key => 'next_id', :inverse_of => :next base.belongs_to :next, :class_name => base.name, :inverse_of => :previous base.after_create :include_in_list! base.after_destroy :delete_from_list end |