This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
No gems have been built for this project yet.
dm-more / dm-is-list
| name | age | message | |
|---|---|---|---|
| .. | |||
| |
History.txt | Wed Jul 16 09:52:55 -0700 2008 | [bernerdschaefer] |
| |
LICENSE | Thu Jun 19 06:21:38 -0700 2008 | [somebee] |
| |
Manifest.txt | Wed Jul 16 09:52:55 -0700 2008 | [bernerdschaefer] |
| |
README.txt | Wed Jul 16 09:52:55 -0700 2008 | [bernerdschaefer] |
| |
Rakefile | Thu Jul 24 14:00:08 -0700 2008 | [bernerdschaefer] |
| |
TODO | Thu Jun 19 12:47:13 -0700 2008 | [dkubb] |
| |
lib/ | Tue Sep 02 05:41:38 -0700 2008 | [somebee] |
| |
spec/ | Tue Sep 02 05:34:32 -0700 2008 | [somebee] |
README.txt
= dm-is-list
DataMapper plugin for creating and organizing lists.
== Installation
Download dm-more and install dm-is-list. Remember to require it in your app.
== Getting started
Lets say we have a user-class, and we want to give users the possibility of
having their own todo-lists
class Todo
include DataMapper::Resource
property :id, Serial
property :title, String
property :done, DateTime
belongs_to :user
# here we define that this should be a list, scoped on :user_id
is :list, :scope => [:user_id]
end
You can now move objects around like this:
item = Todo.get(1)
other = Todo.get(2)
item.move(:highest) # moves to top of list
item.move(:lowest) # moves to bottom of list
item.move(:up) # moves one up (:higher and :up is the same)
item.move(:down) # moves one up (:lower and :down is the same)
item.move(:to => position) # moves item to a specific position
item.move(:above => other) # moves item above the other item.*
item.move(:below => other) # moves item above the other item.*
* won't move if the other item is in another scope. (should this be allowed?)
The list will try to act as intelligently as possible. If you set the position
manually, and then save, the list will reorganize itself to correctly:
item.position = 3 # setting position manually
item.save # the list will now move the item correctly, and updating others
If you move items between scopes, the list will also try to do what you most
likely want to do:
item.user_id # => 1
item.user_id = 2 # giving this item to another user
item.save # the list will now have detached item from old list, and inserted
# at the bottom of the new (user 2) list.
If something is not behaving intuitively, it is a bug, and should be reported.
Report it here: http://wm.lighthouseapp.com/projects/4819-datamapper/overview




