custom_fields 2.6.0 → 2.7.0.rc1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc70111716eabee45d9c1d76bbca61109a7085ac
|
4
|
+
data.tar.gz: e41472ca2346957d15cdb72fedb1dc3772a0ff7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9f2dd50ac8ba4e204442b2452e48544a2d79635bbf94d7298a916804a0a22de68a0368df68bc3091d7836bd2a5e6c7aad45f6f65f192ea339595a698057440b
|
7
|
+
data.tar.gz: dca236e8c22c611a111556e8050e8dfeae26ec2e5308d2d5344f60a0e1575a56a3328958a012ac1fea646c88d428a2d03e5500b1a1051f6abb6e523e0a52ec74
|
@@ -35,7 +35,7 @@ module Mongoid #:nodoc
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.fallbacks?
|
38
|
-
!self.instance.fallbacks.blank? || ::I18n.respond_to?(:fallbacks)
|
38
|
+
!self.instance.fallbacks.blank? || (::I18n.respond_to?(:fallbacks) && !::I18n.fallbacks.blank?)
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.clear_fallbacks
|
@@ -21,6 +21,7 @@ module CustomFields
|
|
21
21
|
name = rule['name']
|
22
22
|
|
23
23
|
klass.mount_uploader name, FileUploader
|
24
|
+
klass.field :"#{name}_size", type: ::Hash, default: {}
|
24
25
|
|
25
26
|
if rule['localized'] == true
|
26
27
|
klass.replace_field name, ::String, true
|
@@ -83,6 +84,21 @@ module CustomFields
|
|
83
84
|
end
|
84
85
|
|
85
86
|
class FileUploader < ::CarrierWave::Uploader::Base
|
87
|
+
|
88
|
+
process :set_size_in_model
|
89
|
+
|
90
|
+
def set_size_in_model
|
91
|
+
size_field_name = :"#{mounted_as}_size"
|
92
|
+
|
93
|
+
if model.respond_to?(size_field_name)
|
94
|
+
is_localized = model.fields[mounted_as.to_s].options[:localize]
|
95
|
+
key = is_localized ? ::Mongoid::Fields::I18n.locale.to_s : 'default'
|
96
|
+
values = model.send(size_field_name)
|
97
|
+
|
98
|
+
values[key] = file.size
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
86
102
|
end
|
87
103
|
|
88
104
|
end
|
@@ -164,10 +164,12 @@ module CustomFields
|
|
164
164
|
|
165
165
|
name = if !option['name'].respond_to?(:merge)
|
166
166
|
option['name']
|
167
|
+
elsif option['name'].has_key?(locale)
|
168
|
+
option['name'][locale.to_s]
|
167
169
|
elsif Mongoid::Fields::I18n.fallbacks?
|
168
170
|
option['name'][Mongoid::Fields::I18n.fallbacks[locale.to_sym].map(&:to_s).find { |loc| !option['name'][loc].nil? }]
|
169
171
|
else
|
170
|
-
|
172
|
+
nil
|
171
173
|
end
|
172
174
|
|
173
175
|
{ '_id' => option['_id'], 'name' => name }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.0
|
19
|
+
version: 5.1.0
|
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: 5.0
|
26
|
+
version: 5.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: carrierwave-mongoid
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|