mongoid_orderable 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +58 -0
- data/lib/mongoid_orderable/version.rb +1 -1
- metadata +7 -7
- data/README +0 -0
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# What?
|
2
|
+
|
3
|
+
Mongoid::Orderable is a ordered list implementation for your mongoid models.
|
4
|
+
|
5
|
+
# Why?
|
6
|
+
|
7
|
+
* It uses native mongo batch increment feature
|
8
|
+
* It supports assignable api
|
9
|
+
* It proper assingns position while moving document between scopes
|
10
|
+
|
11
|
+
# How?
|
12
|
+
|
13
|
+
```
|
14
|
+
gem 'mongoid_orderable'
|
15
|
+
```
|
16
|
+
|
17
|
+
Gem has the same api as others. Just include Mongoid::Orderable into your model.
|
18
|
+
Also you can initialize orderable manually and specify `:scope` or `:column` options:
|
19
|
+
|
20
|
+
```
|
21
|
+
class Item
|
22
|
+
include Mongoid::Document
|
23
|
+
include Mongoid::Orderable
|
24
|
+
|
25
|
+
# belongs_to :group
|
26
|
+
|
27
|
+
# orderable :scope => :group, :column => :pos
|
28
|
+
# orderable :scope => lambda { |document| where(:group_id => document.group_id) }
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
# Usage
|
33
|
+
|
34
|
+
```
|
35
|
+
item.move_to 2 # just change position
|
36
|
+
item.move_to! 2 # and save
|
37
|
+
item.move_to = 2 # assignable method
|
38
|
+
|
39
|
+
# symbol position
|
40
|
+
item.move_to :top
|
41
|
+
item.move_to :bottom
|
42
|
+
item.move_to :higher
|
43
|
+
item.move_to :lower
|
44
|
+
|
45
|
+
# generated methods
|
46
|
+
item.move_to_top
|
47
|
+
item.move_to_bottom
|
48
|
+
item.move_higher
|
49
|
+
item.move_lower
|
50
|
+
```
|
51
|
+
|
52
|
+
# Contributing
|
53
|
+
|
54
|
+
Fork && Patch && Spec && Push && Pull request.
|
55
|
+
|
56
|
+
# License
|
57
|
+
|
58
|
+
Mongoid::Orderable is released under the MIT license.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_orderable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &21250020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *21250020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mongoid
|
27
|
-
requirement: &
|
27
|
+
requirement: &21298420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *21298420
|
36
36
|
description: Gem allows mongoid model behave as orderable list
|
37
37
|
email:
|
38
38
|
- kinwizard@gmail.com
|
@@ -44,7 +44,7 @@ files:
|
|
44
44
|
- .rspec
|
45
45
|
- .rvmrc
|
46
46
|
- Gemfile
|
47
|
-
- README
|
47
|
+
- README.md
|
48
48
|
- Rakefile
|
49
49
|
- lib/mongoid/orderable.rb
|
50
50
|
- lib/mongoid_orderable.rb
|
data/README
DELETED
File without changes
|