custom_fields 2.12.1 → 2.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +4 -5
- data/lib/custom_fields/extensions/active_support.rb +22 -23
- data/lib/custom_fields/extensions/carrierwave.rb +9 -40
- data/lib/custom_fields/extensions/mongoid/association/referenced/has_many.rb +49 -0
- data/lib/custom_fields/extensions/mongoid/association/referenced/has_one.rb +17 -0
- data/lib/custom_fields/extensions/mongoid/association/relatable.rb +30 -0
- data/lib/custom_fields/extensions/mongoid/criteria/queryable/smash.rb +3 -6
- data/lib/custom_fields/extensions/mongoid/document.rb +4 -8
- data/lib/custom_fields/extensions/mongoid/factory.rb +7 -9
- data/lib/custom_fields/extensions/mongoid/fields/i18n.rb +17 -17
- data/lib/custom_fields/extensions/mongoid/fields/localized.rb +21 -21
- data/lib/custom_fields/extensions/mongoid/fields.rb +4 -7
- data/lib/custom_fields/extensions/mongoid/validatable/collection_size.rb +86 -0
- data/lib/custom_fields/extensions/mongoid/{validations → validatable}/macros.rb +3 -2
- data/lib/custom_fields/extensions/origin/smash.rb +4 -5
- data/lib/custom_fields/field.rb +39 -36
- data/lib/custom_fields/source.rb +46 -44
- data/lib/custom_fields/target.rb +11 -12
- data/lib/custom_fields/target_helpers.rb +21 -23
- data/lib/custom_fields/types/belongs_to.rb +6 -20
- data/lib/custom_fields/types/boolean.rb +5 -12
- data/lib/custom_fields/types/color.rb +4 -12
- data/lib/custom_fields/types/date.rb +20 -22
- data/lib/custom_fields/types/date_time.rb +16 -18
- data/lib/custom_fields/types/default.rb +16 -24
- data/lib/custom_fields/types/email.rb +6 -13
- data/lib/custom_fields/types/file.rb +26 -35
- data/lib/custom_fields/types/float.rb +10 -13
- data/lib/custom_fields/types/has_many.rb +12 -16
- data/lib/custom_fields/types/integer.rb +10 -13
- data/lib/custom_fields/types/json.rb +18 -29
- data/lib/custom_fields/types/many_to_many.rb +14 -19
- data/lib/custom_fields/types/money.rb +34 -35
- data/lib/custom_fields/types/password.rb +19 -23
- data/lib/custom_fields/types/relationship_default.rb +4 -16
- data/lib/custom_fields/types/select.rb +43 -51
- data/lib/custom_fields/types/string.rb +5 -13
- data/lib/custom_fields/types/tags.rb +11 -11
- data/lib/custom_fields/types/text.rb +4 -16
- data/lib/custom_fields/version.rb +4 -2
- data/lib/custom_fields.rb +16 -16
- metadata +38 -38
- data/lib/custom_fields/extensions/mongoid/relations/options.rb +0 -19
- data/lib/custom_fields/extensions/mongoid/relations/referenced/in.rb +0 -18
- data/lib/custom_fields/extensions/mongoid/relations/referenced/many.rb +0 -30
- data/lib/custom_fields/extensions/mongoid/validations/collection_size.rb +0 -43
@@ -1,11 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module CustomFields
|
3
4
|
module Types
|
4
|
-
|
5
5
|
module Select
|
6
|
-
|
7
6
|
class Option
|
8
|
-
|
9
7
|
include Mongoid::Document
|
10
8
|
|
11
9
|
field :name, localize: true
|
@@ -15,68 +13,66 @@ module CustomFields
|
|
15
13
|
|
16
14
|
validates_presence_of :name
|
17
15
|
|
18
|
-
def as_json(
|
19
|
-
super methods: %w
|
16
|
+
def as_json(_options = nil)
|
17
|
+
super methods: %w[_id name position]
|
20
18
|
end
|
21
|
-
|
22
19
|
end
|
23
20
|
|
24
21
|
module Field
|
25
|
-
|
26
22
|
extend ActiveSupport::Concern
|
27
23
|
|
28
24
|
included do
|
29
|
-
|
30
25
|
embeds_many :select_options, class_name: 'CustomFields::Types::Select::Option'
|
31
26
|
|
32
27
|
validates_associated :select_options
|
33
28
|
|
34
29
|
accepts_nested_attributes_for :select_options, allow_destroy: true
|
35
|
-
|
36
30
|
end
|
37
31
|
|
38
32
|
def ordered_select_options
|
39
|
-
|
33
|
+
select_options.sort { |a, b| (a.position || 0) <=> (b.position || 0) }.to_a
|
40
34
|
end
|
41
35
|
|
42
36
|
def select_to_recipe
|
43
37
|
{
|
44
|
-
'select_options' =>
|
38
|
+
'select_options' => ordered_select_options.map do |option|
|
45
39
|
{ '_id' => option._id, 'name' => option.name_translations }
|
46
40
|
end
|
47
41
|
}
|
48
42
|
end
|
49
43
|
|
50
|
-
def select_as_json(
|
51
|
-
{ 'select_options' =>
|
44
|
+
def select_as_json(_options = {})
|
45
|
+
{ 'select_options' => ordered_select_options.map(&:as_json) }
|
52
46
|
end
|
53
|
-
|
54
47
|
end
|
55
48
|
|
56
49
|
module Target
|
57
|
-
|
58
50
|
extend ActiveSupport::Concern
|
59
51
|
|
60
52
|
module ClassMethods
|
61
|
-
|
62
53
|
# Adds a select field
|
63
54
|
#
|
64
55
|
# @param [ Class ] klass The class to modify
|
65
56
|
# @param [ Hash ] rule It contains the name of the field and if it is required or not
|
66
57
|
#
|
67
58
|
def apply_select_custom_field(klass, rule)
|
68
|
-
name
|
59
|
+
name = rule['name']
|
60
|
+
base_collection_name = "#{rule['name']}_options".to_sym
|
69
61
|
|
70
|
-
klass.field :"#{name}_id", type: BSON::ObjectId, localize: rule['localized'] || false, default:
|
62
|
+
klass.field :"#{name}_id", type: BSON::ObjectId, localize: rule['localized'] || false, default: lambda {
|
63
|
+
_set_select_option(name, rule['default'])
|
64
|
+
}
|
71
65
|
|
72
66
|
klass.cattr_accessor "_raw_#{base_collection_name}"
|
73
|
-
klass.send :"_raw_#{base_collection_name}=", rule['select_options'].sort { |a, b|
|
67
|
+
klass.send :"_raw_#{base_collection_name}=", rule['select_options'].sort { |a, b|
|
68
|
+
a['position'] <=> b['position']
|
69
|
+
}
|
74
70
|
|
75
71
|
# other methods
|
76
72
|
klass.send(:define_method, name.to_sym) { _get_select_option(name) }
|
77
73
|
klass.send(:define_method, :"#{name}=") { |value| _set_select_option(name, value) }
|
78
74
|
|
79
|
-
klass.class_eval <<-EOV
|
75
|
+
klass.class_eval <<-EOV, __FILE__, __LINE__ + 1
|
80
76
|
|
81
77
|
def self.#{base_collection_name}
|
82
78
|
self._select_options('#{name}')
|
@@ -84,9 +80,9 @@ module CustomFields
|
|
84
80
|
|
85
81
|
EOV
|
86
82
|
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
return unless rule['required']
|
84
|
+
|
85
|
+
klass.validates_presence_of name
|
90
86
|
end
|
91
87
|
|
92
88
|
# Build a hash storing the values (id and option name) for
|
@@ -100,8 +96,8 @@ module CustomFields
|
|
100
96
|
def select_attribute_get(instance, name)
|
101
97
|
if value = instance.send(name.to_sym)
|
102
98
|
{
|
103
|
-
name
|
104
|
-
"#{name}_id"
|
99
|
+
name => value,
|
100
|
+
"#{name}_id" => instance.send(:"#{name}_id")
|
105
101
|
}
|
106
102
|
else
|
107
103
|
{}
|
@@ -116,7 +112,7 @@ module CustomFields
|
|
116
112
|
# @param [ Hash ] attributes The attributes used to fetch the values
|
117
113
|
#
|
118
114
|
def select_attribute_set(instance, name, attributes)
|
119
|
-
id_or_name
|
115
|
+
id_or_name = attributes[name] || attributes["#{name}_id"]
|
120
116
|
|
121
117
|
return if id_or_name.nil?
|
122
118
|
|
@@ -134,7 +130,7 @@ module CustomFields
|
|
134
130
|
#
|
135
131
|
def group_by_select_option(name, order_by = nil)
|
136
132
|
name_id = "#{name}_id"
|
137
|
-
groups =
|
133
|
+
groups = each.group_by { |x| x.send(name_id) }.map do |(k, v)|
|
138
134
|
{ name_id => k, 'group' => v }
|
139
135
|
end
|
140
136
|
|
@@ -144,33 +140,32 @@ module CustomFields
|
|
144
140
|
|
145
141
|
groups.delete(group) if group
|
146
142
|
|
147
|
-
{ name: option['name'], entries:
|
143
|
+
{ name: option['name'], entries: _order_select_entries(list, order_by) }.with_indifferent_access
|
148
144
|
end.tap do |array|
|
149
|
-
|
145
|
+
unless groups.empty? # orphan entries ?
|
150
146
|
empty = { name: nil, entries: [] }.with_indifferent_access
|
151
147
|
groups.each do |group|
|
152
148
|
empty[:entries] += group['group']
|
153
149
|
end
|
154
|
-
empty[:entries] =
|
150
|
+
empty[:entries] = _order_select_entries(empty[:entries], order_by)
|
155
151
|
array << empty
|
156
152
|
end
|
157
153
|
end
|
158
154
|
end
|
159
155
|
|
160
156
|
def _select_options(name)
|
161
|
-
|
162
|
-
|
157
|
+
send(:"_raw_#{name}_options").map do |option|
|
163
158
|
locale = Mongoid::Fields::I18n.locale.to_s
|
164
159
|
|
165
160
|
name = if !option['name'].respond_to?(:merge)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
161
|
+
option['name']
|
162
|
+
elsif option['name'].key?(locale)
|
163
|
+
option['name'][locale.to_s]
|
164
|
+
elsif Mongoid::Fields::I18n.fallbacks?
|
165
|
+
option['name'][Mongoid::Fields::I18n.fallbacks[locale.to_sym].map(&:to_s).find do |loc|
|
166
|
+
!option['name'][loc].nil?
|
167
|
+
end]
|
168
|
+
end
|
174
169
|
|
175
170
|
{ '_id' => option['_id'], 'name' => name }
|
176
171
|
end
|
@@ -181,17 +176,18 @@ module CustomFields
|
|
181
176
|
|
182
177
|
column, direction = order_by.flatten
|
183
178
|
|
184
|
-
list = list.sort
|
179
|
+
list = list.sort do |a, b|
|
180
|
+
a.send(column) && b.send(column) ? (a.send(column) || 0) <=> (b.send(column) || 0) : 0
|
181
|
+
end
|
185
182
|
|
186
183
|
direction == 'asc' ? list : list.reverse
|
187
184
|
|
188
185
|
list
|
189
186
|
end
|
190
|
-
|
191
187
|
end
|
192
188
|
|
193
189
|
def _select_option_id(name)
|
194
|
-
|
190
|
+
send(:"#{name}_id")
|
195
191
|
end
|
196
192
|
|
197
193
|
def _find_select_option(name, id_or_name)
|
@@ -201,19 +197,15 @@ module CustomFields
|
|
201
197
|
end
|
202
198
|
|
203
199
|
def _get_select_option(name)
|
204
|
-
option =
|
200
|
+
option = _find_select_option(name, _select_option_id(name))
|
205
201
|
option ? option['name'] : nil
|
206
202
|
end
|
207
203
|
|
208
204
|
def _set_select_option(name, value)
|
209
|
-
option =
|
210
|
-
|
205
|
+
option = _find_select_option(name, value)
|
206
|
+
send(:"#{name}_id=", option ? option['_id'] : nil)
|
211
207
|
end
|
212
|
-
|
213
208
|
end
|
214
|
-
|
215
209
|
end
|
216
|
-
|
217
210
|
end
|
218
|
-
|
219
211
|
end
|
@@ -1,17 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module CustomFields
|
3
4
|
module Types
|
4
|
-
|
5
5
|
module String
|
6
|
-
|
7
6
|
module Field; end
|
8
7
|
|
9
8
|
module Target
|
10
|
-
|
11
9
|
extend ActiveSupport::Concern
|
12
10
|
|
13
11
|
module ClassMethods
|
14
|
-
|
15
12
|
# Add a string field
|
16
13
|
#
|
17
14
|
# @param [ Class ] klass The class to modify
|
@@ -30,7 +27,7 @@ module CustomFields
|
|
30
27
|
# @return [ Hash ] field name => raw value
|
31
28
|
#
|
32
29
|
def string_attribute_get(instance, name)
|
33
|
-
|
30
|
+
default_attribute_get(instance, name)
|
34
31
|
end
|
35
32
|
|
36
33
|
# Set the value for the instance and the string field specified by
|
@@ -41,15 +38,10 @@ module CustomFields
|
|
41
38
|
# @param [ Hash ] attributes The attributes used to fetch the values
|
42
39
|
#
|
43
40
|
def string_attribute_set(instance, name, attributes)
|
44
|
-
|
41
|
+
default_attribute_set(instance, name, attributes)
|
45
42
|
end
|
46
|
-
|
47
43
|
end
|
48
|
-
|
49
44
|
end
|
50
|
-
|
51
45
|
end
|
52
|
-
|
53
46
|
end
|
54
|
-
|
55
|
-
end
|
47
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module CustomFields
|
2
4
|
module Types
|
3
5
|
module Tags
|
4
6
|
module Field; end
|
5
|
-
|
7
|
+
|
6
8
|
module Target
|
7
9
|
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
module ClassMethods
|
10
10
|
|
11
|
+
module ClassMethods
|
11
12
|
def apply_tags_custom_field(klass, rule)
|
12
13
|
klass.field rule['name'], localize: rule['localized'] || false, type: Array
|
13
|
-
|
14
|
+
|
14
15
|
klass.class_eval do
|
15
16
|
define_method("#{rule['name']}=") do |val|
|
16
|
-
#FIXME I would use is_a?(), but it doesn't work in my machine!
|
17
|
-
val = val.split(/ *, */) if val.class.to_s ==
|
17
|
+
# FIXME: I would use is_a?(), but it doesn't work in my machine!
|
18
|
+
val = val.split(/ *, */) if val.class.to_s == 'String'
|
18
19
|
super(val)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
22
|
-
|
23
|
+
|
23
24
|
def tags_attribute_get(instance, name)
|
24
|
-
|
25
|
+
default_attribute_get(instance, name)
|
25
26
|
end
|
26
27
|
|
27
28
|
def tags_attribute_set(instance, name, attributes)
|
28
|
-
|
29
|
+
default_attribute_set(instance, name, attributes)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -1,27 +1,20 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module CustomFields
|
3
4
|
module Types
|
4
|
-
|
5
5
|
module Text
|
6
|
-
|
7
6
|
module Field
|
8
|
-
|
9
7
|
extend ActiveSupport::Concern
|
10
8
|
|
11
9
|
included do
|
12
|
-
|
13
10
|
field :text_formatting, default: 'html'
|
14
|
-
|
15
11
|
end
|
16
|
-
|
17
12
|
end
|
18
13
|
|
19
14
|
module Target
|
20
|
-
|
21
15
|
extend ActiveSupport::Concern
|
22
16
|
|
23
17
|
module ClassMethods
|
24
|
-
|
25
18
|
# Adds a text field (simply a string field)
|
26
19
|
#
|
27
20
|
# @param [ Class ] klass The class to modify
|
@@ -51,15 +44,10 @@ module CustomFields
|
|
51
44
|
# @param [ Hash ] attributes The attributes used to fetch the values
|
52
45
|
#
|
53
46
|
def text_attribute_set(instance, name, attributes)
|
54
|
-
|
47
|
+
default_attribute_set(instance, name, attributes)
|
55
48
|
end
|
56
|
-
|
57
49
|
end
|
58
|
-
|
59
50
|
end
|
60
|
-
|
61
51
|
end
|
62
|
-
|
63
52
|
end
|
64
|
-
|
65
|
-
end
|
53
|
+
end
|
data/lib/custom_fields.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift __dir__
|
2
4
|
|
3
5
|
require 'active_support'
|
4
6
|
require 'carrierwave/mongoid'
|
@@ -8,10 +10,12 @@ require 'bcrypt'
|
|
8
10
|
Money.locale_backend = :currency
|
9
11
|
|
10
12
|
module CustomFields
|
13
|
+
# Regexp to check if a Ruby class has been built by the CustomFields gem
|
14
|
+
KLASS_REGEXP = /(.*)([0-9a-fA-F]{24})$/o
|
11
15
|
|
12
16
|
@@options = {
|
13
|
-
reserved_names:
|
14
|
-
default_currency:
|
17
|
+
reserved_names: Mongoid.destructive_fields + %w[id _id send class destroy system],
|
18
|
+
default_currency: 'EUR'
|
15
19
|
}
|
16
20
|
|
17
21
|
def self.options=(options)
|
@@ -21,23 +25,22 @@ module CustomFields
|
|
21
25
|
def self.options
|
22
26
|
@@options
|
23
27
|
end
|
24
|
-
|
25
28
|
end
|
26
29
|
|
27
|
-
%w
|
30
|
+
%w[ version
|
28
31
|
extensions/active_support
|
29
32
|
extensions/carrierwave
|
30
33
|
extensions/mongoid/document
|
31
34
|
extensions/mongoid/factory
|
32
35
|
extensions/mongoid/criteria/queryable/smash
|
33
|
-
extensions/mongoid/
|
34
|
-
extensions/mongoid/
|
35
|
-
extensions/mongoid/
|
36
|
+
extensions/mongoid/association/relatable
|
37
|
+
extensions/mongoid/association/referenced/has_many
|
38
|
+
extensions/mongoid/association/referenced/has_one
|
36
39
|
extensions/mongoid/fields.rb
|
37
40
|
extensions/mongoid/fields/i18n.rb
|
38
41
|
extensions/mongoid/fields/localized.rb
|
39
|
-
extensions/mongoid/
|
40
|
-
extensions/mongoid/
|
42
|
+
extensions/mongoid/validatable/collection_size.rb
|
43
|
+
extensions/mongoid/validatable/macros.rb
|
41
44
|
extensions/origin/smash.rb
|
42
45
|
types/default
|
43
46
|
types/string
|
@@ -62,21 +65,18 @@ end
|
|
62
65
|
field
|
63
66
|
source
|
64
67
|
target_helpers
|
65
|
-
target
|
66
|
-
|
67
|
-
|
68
|
-
end
|
68
|
+
target].each do |lib|
|
69
|
+
require_relative "./custom_fields/#{lib}"
|
70
|
+
end
|
69
71
|
|
70
72
|
# Load all the translation files
|
71
73
|
I18n.load_path += Dir[File.join(File.dirname(__FILE__), '..', 'config', 'locales', '*.yml')]
|
72
74
|
|
73
75
|
module MyBenchmark
|
74
|
-
|
75
76
|
def self.measure(caption, &block)
|
76
77
|
t1 = Time.now
|
77
78
|
returned_value = block.call
|
78
79
|
puts "[MyBenchmark] #{caption} took #{((Time.now - t1) * 1000).to_i} ms"
|
79
80
|
returned_value
|
80
81
|
end
|
81
|
-
|
82
82
|
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '5'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: bcrypt
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.
|
39
|
+
version: 3.1.18
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.
|
46
|
+
version: 3.1.18
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: carrierwave-mongoid
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '5.1'
|
54
|
-
- - "<"
|
51
|
+
- - "~>"
|
55
52
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
53
|
+
version: 1.4.0
|
57
54
|
type: :runtime
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
|
-
- - "
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '5.1'
|
64
|
-
- - "<"
|
58
|
+
- - "~>"
|
65
59
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
60
|
+
version: 1.4.0
|
67
61
|
- !ruby/object:Gem::Dependency
|
68
62
|
name: monetize
|
69
63
|
requirement: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
65
|
- - "~>"
|
72
66
|
- !ruby/object:Gem::Version
|
73
|
-
version: 1.
|
67
|
+
version: 1.12.0
|
74
68
|
type: :runtime
|
75
69
|
prerelease: false
|
76
70
|
version_requirements: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
72
|
- - "~>"
|
79
73
|
- !ruby/object:Gem::Version
|
80
|
-
version: 1.
|
74
|
+
version: 1.12.0
|
81
75
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
76
|
+
name: mongoid
|
83
77
|
requirement: !ruby/object:Gem::Requirement
|
84
78
|
requirements:
|
85
|
-
- - "
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '7'
|
82
|
+
- - "<"
|
86
83
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
84
|
+
version: '8.0'
|
88
85
|
type: :runtime
|
89
86
|
prerelease: false
|
90
87
|
version_requirements: !ruby/object:Gem::Requirement
|
91
88
|
requirements:
|
92
|
-
- - "
|
89
|
+
- - ">="
|
93
90
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
91
|
+
version: '7'
|
92
|
+
- - "<"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '8.0'
|
95
95
|
description: Manage custom fields to a Mongoid document or a collection. This module
|
96
96
|
is one of the core features we implemented in our custom CMS, named LocomotiveCMS.
|
97
97
|
email: didier@nocoffee.fr
|
@@ -111,17 +111,17 @@ files:
|
|
111
111
|
- lib/custom_fields.rb
|
112
112
|
- lib/custom_fields/extensions/active_support.rb
|
113
113
|
- lib/custom_fields/extensions/carrierwave.rb
|
114
|
+
- lib/custom_fields/extensions/mongoid/association/referenced/has_many.rb
|
115
|
+
- lib/custom_fields/extensions/mongoid/association/referenced/has_one.rb
|
116
|
+
- lib/custom_fields/extensions/mongoid/association/relatable.rb
|
114
117
|
- lib/custom_fields/extensions/mongoid/criteria/queryable/smash.rb
|
115
118
|
- lib/custom_fields/extensions/mongoid/document.rb
|
116
119
|
- lib/custom_fields/extensions/mongoid/factory.rb
|
117
120
|
- lib/custom_fields/extensions/mongoid/fields.rb
|
118
121
|
- lib/custom_fields/extensions/mongoid/fields/i18n.rb
|
119
122
|
- lib/custom_fields/extensions/mongoid/fields/localized.rb
|
120
|
-
- lib/custom_fields/extensions/mongoid/
|
121
|
-
- lib/custom_fields/extensions/mongoid/
|
122
|
-
- lib/custom_fields/extensions/mongoid/relations/referenced/many.rb
|
123
|
-
- lib/custom_fields/extensions/mongoid/validations/collection_size.rb
|
124
|
-
- lib/custom_fields/extensions/mongoid/validations/macros.rb
|
123
|
+
- lib/custom_fields/extensions/mongoid/validatable/collection_size.rb
|
124
|
+
- lib/custom_fields/extensions/mongoid/validatable/macros.rb
|
125
125
|
- lib/custom_fields/extensions/origin/smash.rb
|
126
126
|
- lib/custom_fields/field.rb
|
127
127
|
- lib/custom_fields/source.rb
|
@@ -152,15 +152,15 @@ homepage: https://github.com/locomotivecms/custom_fields
|
|
152
152
|
licenses:
|
153
153
|
- MIT
|
154
154
|
metadata: {}
|
155
|
-
post_install_message:
|
155
|
+
post_install_message:
|
156
156
|
rdoc_options: []
|
157
157
|
require_paths:
|
158
158
|
- lib
|
159
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
160
|
requirements:
|
161
|
-
- - "
|
161
|
+
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '2.
|
163
|
+
version: '2.7'
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubygems_version: 3.2.32
|
171
|
-
signing_key:
|
171
|
+
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Custom fields extension for Mongoid.
|
174
174
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Mongoid
|
3
|
-
module Relations
|
4
|
-
|
5
|
-
module Options
|
6
|
-
|
7
|
-
def validate_with_custom_fields!(options)
|
8
|
-
_options = options.dup
|
9
|
-
_options.delete(:custom_fields_parent_klass)
|
10
|
-
validate_without_custom_fields!(_options)
|
11
|
-
end
|
12
|
-
|
13
|
-
alias_method :validate_without_custom_fields!, :validate!
|
14
|
-
alias_method :validate!, :validate_with_custom_fields!
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Mongoid # :nodoc:
|
2
|
-
module Relations #:nodoc:
|
3
|
-
module Referenced #:nodoc:
|
4
|
-
|
5
|
-
class In < Relations::One
|
6
|
-
class << self
|
7
|
-
def valid_options_with_parent_class
|
8
|
-
valid_options_without_parent_class.push :custom_fields_parent_klass
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method :valid_options_without_parent_class, :valid_options
|
12
|
-
alias_method :valid_options, :valid_options_with_parent_class
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|