Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update Rakefile\n Add some initial documentation

  • Loading branch information...
commit 1a39c1b753d8e83a02190da9226bd49142246296 1 parent e337217
Paweł Kondzior authored
Showing with 26 additions and 6 deletions.
  1. +5 −5 Rakefile
  2. +21 −1 lib/sequel_nested_set.rb
View
10 Rakefile
@@ -2,12 +2,12 @@
# Constants
##############################################################################
-PluginName = "sequel_timestamped"
-Version = "0.0.1"
-Title = "Timestamped Sequel Plugin"
-Summary = "Sequel Plugin"
+PluginName = "sequel_nested_set"
+Version = "0.5"
+Title = "Nested Set Sequel Plugin"
+Summary = "Sequel Nested Set Plugin"
Authors = "Brian Cooke"
-Emails = "cookebri@gmail.com"
+Emails = "kondzior.p@gmail.com"
Homepage = "http://sequel.rubyforge.org"
##############################################################################
View
22 lib/sequel_nested_set.rb
@@ -1,7 +1,27 @@
module Sequel
module Plugins
+ # This acts provides Nested Set functionality. Nested Set is a smart way to implement
+ # an _ordered_ tree, with the added feature that you can select the children and all of their
+ # descendants with a single query. The drawback is that insertion or move need some complex
+ # sql queries. But everything is done here by this module!
+ #
+ # Nested sets are appropriate each time you want either an orderd tree (menus,
+ # commercial categories) or an efficient way of querying big trees (threaded posts).
+ #
+ # == API
+ #
+ # # adds a new item at the "end" of the tree, i.e. with child.left = max(tree.right)+1
+ # child = MyClass.new(:name => "child1")
+ # child.save
+ # # now move the item to its right place
+ # child.move_to_child_of my_item
+ #
+ # You can pass an id or an object to:
+ # * <tt>#move_to_child_of</tt>
+ # * <tt>#move_to_right_of</tt>
+ # * <tt>#move_to_left_of</tt>
+ #
module NestedSet
- # Apply the plugin to the model.
def self.apply(model, options = {})
options = {
:parent_column => :parent_id,
Please sign in to comment.
Something went wrong with that request. Please try again.