custom_fields 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2b705c9d565edfff9e7a521cd52e97ed7259323
4
- data.tar.gz: 61b63be379d8181d08a6a1adca3bf08208ffe993
3
+ metadata.gz: 72c3c8e193eb2324800d6718260672b8a1bd6aaf
4
+ data.tar.gz: 269f5073245c71a88b20eb1da47cacab116c55c0
5
5
  SHA512:
6
- metadata.gz: e5a0d31ff44f359c071e4f6e50463109d99f465acd4610372b0af09afc5b058565460a91923e646bff5274f0942e4a0a2611dae007d3845134f7608eaed852ae
7
- data.tar.gz: 0aec87c37bbb221f6cb781ffcd52dea2cc26bfdc008f6259414097bd95d694de28085537a059bb54fa5f883bf699d6f4cddca7d884f46b7c3965d1756bba5f1f
6
+ metadata.gz: db1aef98d5992fd7611e64b469c01216c9ccecf101aecdee36060418cc5993142661d8fd852e0f095917df93dc6a7e951971a451720696d56e0769d3be787b0b
7
+ data.tar.gz: 75cf473439bb423f18b48223ac252b798eb3d45d4280157aa49f9a87fdca7e528a25ddee64a8187def6b4045f7d7cf65bab1d7624c60aa24251d8cb138e5ce80
@@ -7,10 +7,12 @@ module Mongoid # :nodoc:
7
7
 
8
8
  class << self
9
9
 
10
- def valid_options
11
- [:autosave, :foreign_key, :index, :polymorphic, :custom_fields_parent_klass]
10
+ def valid_options_with_parent_class
11
+ valid_options_without_parent_class.push :custom_fields_parent_klass
12
12
  end
13
13
 
14
+ alias_method_chain :valid_options, :parent_class
15
+
14
16
  end
15
17
 
16
18
  end
@@ -172,9 +172,12 @@ module CustomFields
172
172
  operations['$set'].merge!({ 'custom_fields_recipe.version' => self.custom_fields_version(name) })
173
173
  collection, selector = self.send(name).collection, self.send(name).criteria.selector
174
174
 
175
- # puts "selector = #{selector.inspect}, memo = #{attributes.inspect}" # DEBUG
176
-
177
- collection.find(selector).update operations, multi: true
175
+ # http://docs.mongodb.org/manual/reference/method/db.collection.update/#update-parameter
176
+ # The <update> document must contain only update operator expressions.
177
+ %w(set unset rename).each do |operation_name|
178
+ _operations = { "$#{operation_name}" => operations.delete("$#{operation_name}") }
179
+ collection.find(selector).update _operations, multi: true
180
+ end
178
181
  end
179
182
 
180
183
  # If the localized attribute has been changed in at least one of the custom fields,
@@ -73,6 +73,8 @@ module CustomFields
73
73
  # @return [ Class ] the custom klass
74
74
  #
75
75
  def klass_with_custom_fields(recipe)
76
+ return self if recipe.blank? # no recipe provided
77
+
76
78
  name = recipe['name']
77
79
 
78
80
  (modules = self.name.split('::')).pop
@@ -34,7 +34,7 @@ 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_has_many_custom_field(klass, rule)
37
- # puts "#{klass.inspect}.has_many #{rule['name'].inspect}, class_name: #{rule['class_name'].inspect}, inverse_of: #{rule['inverse_of']}" # DEBUG
37
+ # puts "#{klass.inspect}.has_many #{rule['name'].inspect}, class_name: #{rule['class_name'].inspect}, inverse_of: #{rule['inverse_of']}, order_by: #{rule['order_by'].inspect}" # DEBUG
38
38
  position_name = "position_in_#{rule['inverse_of']}"
39
39
 
40
40
  _order_by = rule['order_by'] || position_name.to_sym.asc
@@ -43,7 +43,7 @@ module CustomFields
43
43
  klass.has_many rule['name'], class_name: rule['class_name'], inverse_of: _inverse_of, order: _order_by do
44
44
 
45
45
  def filtered(conditions = {}, order_by = nil)
46
- list = conditions.empty? ? self : self.where(conditions)
46
+ list = conditions.empty? ? self.unscoped : self.where(conditions)
47
47
 
48
48
  if order_by
49
49
  list.order_by(order_by)
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module CustomFields #:nodoc
3
3
 
4
- VERSION = '2.3.1'
4
+ VERSION = '2.3.2'
5
5
 
6
6
  end
metadata CHANGED
@@ -1,167 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.3
19
+ version: 3.1.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.3
26
+ version: 3.1.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.2.13
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.2.13
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: carrierwave-mongoid
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: money
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '5.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.7.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.7.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mocha
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.9.12
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.12
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '2.6'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.6'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.6.1
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.6.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: database_cleaner
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 0.9.1
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.9.1
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: pry
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: RedCloth
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: 4.2.8
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 4.2.8
167
167
  description: Manage custom fields to a mongoid document or a collection. This module
@@ -176,13 +176,19 @@ extra_rdoc_files:
176
176
  files:
177
177
  - MIT-LICENSE
178
178
  - README.textile
179
+ - config/locales/de.yml
180
+ - config/locales/en.yml
181
+ - config/locales/fr.yml
182
+ - config/locales/pt-BR.yml
183
+ - config/locales/ru.yml
184
+ - lib/custom_fields.rb
179
185
  - lib/custom_fields/extensions/active_support.rb
180
186
  - lib/custom_fields/extensions/carrierwave.rb
181
187
  - lib/custom_fields/extensions/mongoid/document.rb
182
188
  - lib/custom_fields/extensions/mongoid/factory.rb
189
+ - lib/custom_fields/extensions/mongoid/fields.rb
183
190
  - lib/custom_fields/extensions/mongoid/fields/i18n.rb
184
191
  - lib/custom_fields/extensions/mongoid/fields/localized.rb
185
- - lib/custom_fields/extensions/mongoid/fields.rb
186
192
  - lib/custom_fields/extensions/mongoid/relations/referenced/in.rb
187
193
  - lib/custom_fields/extensions/mongoid/relations/referenced/many.rb
188
194
  - lib/custom_fields/extensions/mongoid/validations/collection_size.rb
@@ -210,12 +216,6 @@ files:
210
216
  - lib/custom_fields/types/tags.rb
211
217
  - lib/custom_fields/types/text.rb
212
218
  - lib/custom_fields/version.rb
213
- - lib/custom_fields.rb
214
- - config/locales/de.yml
215
- - config/locales/en.yml
216
- - config/locales/fr.yml
217
- - config/locales/pt-BR.yml
218
- - config/locales/ru.yml
219
219
  homepage: http://github.com/locomotivecms/custom_fields
220
220
  licenses: []
221
221
  metadata: {}
@@ -225,17 +225,17 @@ require_paths:
225
225
  - lib
226
226
  required_ruby_version: !ruby/object:Gem::Requirement
227
227
  requirements:
228
- - - '>='
228
+ - - ">="
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  requirements:
233
- - - '>='
233
+ - - ">="
234
234
  - !ruby/object:Gem::Version
235
235
  version: 1.3.6
236
236
  requirements: []
237
237
  rubyforge_project: nowarning
238
- rubygems_version: 2.0.7
238
+ rubygems_version: 2.2.2
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: Custom fields extension for Mongoid