custom_fields 2.0.0.rc6 → 2.0.0.rc7
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,10 +11,10 @@ module CustomFields
|
|
11
11
|
included do
|
12
12
|
|
13
13
|
def has_many_to_recipe
|
14
|
-
{ 'class_name' => self.class_name, 'inverse_of' => self.inverse_of }
|
14
|
+
{ 'class_name' => self.class_name, 'inverse_of' => self.inverse_of, 'order_by' => self.order_by }
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def has_many_is_relationship?
|
18
18
|
self.type == 'has_many'
|
19
19
|
end
|
20
20
|
|
@@ -38,7 +38,14 @@ module CustomFields
|
|
38
38
|
|
39
39
|
position_name = "position_in_#{rule['inverse_of']}"
|
40
40
|
|
41
|
-
|
41
|
+
_order_by = rule['order_by'] || position_name.to_sym.asc
|
42
|
+
|
43
|
+
klass.has_many rule['name'], :class_name => rule['class_name'], :inverse_of => rule['inverse_of'], :order => _order_by do
|
44
|
+
def ordered
|
45
|
+
# calling all on a has_many relationship makes us lose the default order_by (mongoid bug ?)
|
46
|
+
order(metadata.order)
|
47
|
+
end
|
48
|
+
end
|
42
49
|
|
43
50
|
klass.accepts_nested_attributes_for rule['name'], :allow_destroy => true
|
44
51
|
|
@@ -11,7 +11,7 @@ module CustomFields
|
|
11
11
|
included do
|
12
12
|
|
13
13
|
def many_to_many_to_recipe
|
14
|
-
{ 'class_name' => self.class_name, 'inverse_of' => self.inverse_of }
|
14
|
+
{ 'class_name' => self.class_name, 'inverse_of' => self.inverse_of, 'order_by' => self.order_by }
|
15
15
|
end
|
16
16
|
|
17
17
|
def many_to_many_is_relationship?
|
@@ -34,9 +34,9 @@ module CustomFields
|
|
34
34
|
# @param [ Hash ] rule It contains the name of the relation and if it is required or not
|
35
35
|
#
|
36
36
|
def apply_many_to_many_custom_field(klass, rule)
|
37
|
-
# puts "#{klass.inspect}.many_to_many #{rule['name'].inspect}, :class_name => #{rule['class_name'].inspect}" # DEBUG
|
37
|
+
# puts "#{klass.inspect}.many_to_many #{rule['name'].inspect}, :class_name => #{rule['class_name'].inspect} / #{rule['order_by']}" # DEBUG
|
38
38
|
|
39
|
-
klass.has_and_belongs_to_many rule['name'], :class_name => rule['class_name'], :inverse_of => rule['inverse_of']
|
39
|
+
klass.has_and_belongs_to_many rule['name'], :class_name => rule['class_name'], :inverse_of => rule['inverse_of'], :order => rule['order_by']
|
40
40
|
|
41
41
|
if rule['required']
|
42
42
|
klass.validates_length_of rule['name'], :minimum => 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.rc7
|
5
5
|
prerelease: 6
|
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: 2012-03-
|
12
|
+
date: 2012-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154925500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.4.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154925500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154924900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.2.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154924900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: carrierwave-mongoid
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154923780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154923780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156059980 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.7.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156059980
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: bson
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156059040 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.3.1
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156059040
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: mongo
|
71
|
-
requirement: &
|
71
|
+
requirement: &2156058460 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.3.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2156058460
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: bson_ext
|
82
|
-
requirement: &
|
82
|
+
requirement: &2156057820 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.3.1
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156057820
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: mocha
|
93
|
-
requirement: &
|
93
|
+
requirement: &2156057160 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 0.9.12
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2156057160
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &2156056580 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,21 @@ dependencies:
|
|
109
109
|
version: '2.6'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2156056580
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: simplecov
|
115
|
+
requirement: &2156056000 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.6.1
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *2156056000
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: database_cleaner
|
115
|
-
requirement: &
|
126
|
+
requirement: &2156055380 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ~>
|
@@ -120,10 +131,10 @@ dependencies:
|
|
120
131
|
version: 0.6.7
|
121
132
|
type: :development
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *2156055380
|
124
135
|
- !ruby/object:Gem::Dependency
|
125
136
|
name: RedCloth
|
126
|
-
requirement: &
|
137
|
+
requirement: &2156054800 !ruby/object:Gem::Requirement
|
127
138
|
none: false
|
128
139
|
requirements:
|
129
140
|
- - ~>
|
@@ -131,7 +142,7 @@ dependencies:
|
|
131
142
|
version: 4.2.8
|
132
143
|
type: :development
|
133
144
|
prerelease: false
|
134
|
-
version_requirements: *
|
145
|
+
version_requirements: *2156054800
|
135
146
|
description: Manage custom fields to a mongoid document or a collection. This module
|
136
147
|
is one of the core features we implemented in our custom cms named Locomotive.
|
137
148
|
email:
|
@@ -188,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
188
199
|
version: '0'
|
189
200
|
segments:
|
190
201
|
- 0
|
191
|
-
hash:
|
202
|
+
hash: 4528261015469024742
|
192
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
204
|
none: false
|
194
205
|
requirements:
|