acts_as_list_mongoid 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +30 -5
- data/VERSION +1 -1
- data/acts_as_list_mongoid.gemspec +2 -2
- data/lib/mongoid/acts_as_list.rb +9 -4
- data/model/embedded_item.rb +1 -4
- data/model/referenced_category.rb +2 -2
- data/spec/acts_as_list/embedded_item_spec.rb +2 -0
- metadata +3 -3
data/README.markdown
CHANGED
@@ -13,6 +13,21 @@ If you do not specify custom position +column+ in the options, a key named +pos+
|
|
13
13
|
|
14
14
|
See the /specs folder specs that demontrate the API. Usage examples are located in the /examples folder.
|
15
15
|
|
16
|
+
## Update 26, Nov 2010
|
17
|
+
|
18
|
+
The gem doesn't seem to work with the latest versions of Mongoid (> beta14), please help fix this ;)
|
19
|
+
Usage has been simplified using a suggestion by 'KieranP'
|
20
|
+
|
21
|
+
To make a class Act as List, simply do:
|
22
|
+
|
23
|
+
<pre>
|
24
|
+
include ActsAsList::Mongoid
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
And it will automatically set up a field and call acts_as_list with that field. By default the field name is :position.
|
28
|
+
You can change the defaut position_column name used: <code>ActsAsList::Mongoid.default_position_column = :pos</code>.
|
29
|
+
For this class variable to be effetive, it should be set before calling <code>include ActsAsList::Mongoid</code>.
|
30
|
+
|
16
31
|
## Example
|
17
32
|
|
18
33
|
<pre>
|
@@ -25,12 +40,9 @@ See the /specs folder specs that demontrate the API. Usage examples are located
|
|
25
40
|
include Mongoid::Document
|
26
41
|
include Mongoid::Timestamps
|
27
42
|
include ActsAsList::Mongoid
|
28
|
-
|
29
|
-
field :pos, :type => Integer
|
43
|
+
|
30
44
|
field :number, :type => Integer
|
31
|
-
|
32
|
-
acts_as_list :column => :pos
|
33
|
-
|
45
|
+
|
34
46
|
embedded_in :list, :inverse_of => :items
|
35
47
|
end
|
36
48
|
|
@@ -53,6 +65,19 @@ See the /specs folder specs that demontrate the API. Usage examples are located
|
|
53
65
|
todo_list.items.last.move(:higher)
|
54
66
|
</pre>
|
55
67
|
|
68
|
+
## Overriding defaults
|
69
|
+
|
70
|
+
By default, when including ActsAsList::Mongoid, the field is set to :pos and the acts_as_list column to :pos.
|
71
|
+
To change this:
|
72
|
+
|
73
|
+
<pre>
|
74
|
+
include ActsAsList::Mongoid
|
75
|
+
|
76
|
+
field :pos, :type => Integer
|
77
|
+
acts_as_list :column => :pos
|
78
|
+
</pre>
|
79
|
+
|
80
|
+
|
56
81
|
### List initialization
|
57
82
|
|
58
83
|
In order for the list items to be initialized properly, it is necessary to call the method <code>init_list!</code> on the
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_list_mongoid}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-27}
|
13
13
|
s.description = %q{Make your Mongoid model acts as a list. This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list.
|
14
14
|
The instances that take part in the list should have a +position+ field of type Integer.}
|
15
15
|
s.email = %q{kmandrup@gmail.com}
|
data/lib/mongoid/acts_as_list.rb
CHANGED
@@ -4,10 +4,15 @@ require 'mongoid_adjust'
|
|
4
4
|
|
5
5
|
module ActsAsList
|
6
6
|
module Mongoid
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
class << self
|
8
|
+
attr_accessor :default_position_column
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.included(klass)
|
12
|
+
klass.extend InitializerMethods
|
13
|
+
key = self.default_position_column || :position
|
14
|
+
klass.field key, :type => Integer
|
15
|
+
klass.acts_as_list :column => key.to_s
|
11
16
|
end
|
12
17
|
|
13
18
|
module InitializerMethods
|
data/model/embedded_item.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-27 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|