carrierwave-serializable 0.0.5 → 0.0.6
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: 82365049a37fc90c0cdf9e0ac27e35a86556c275
|
4
|
+
data.tar.gz: 30037ac9507ba6cb2551566f3db61353d99361d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d227f799b2f810b6736ad0208e51bde94a499432e8bc5160ad7b3d0a4b756e0bd8166a2a2754063528d4cf8599a1f14b9a380c3b6ceb70ab3970ca128f3c93ee
|
7
|
+
data.tar.gz: 2345d755b69a02df0ce3255f3a55f5145dd5e979d0b9f8f28531668d9cae68740f86351c971130a3b874c2482c91992236089da24cac1e74e9652d2096d2c175
|
@@ -6,27 +6,11 @@ module CarrierWave
|
|
6
6
|
module ActiveRecord
|
7
7
|
module Serializable
|
8
8
|
def serialized_uploaders
|
9
|
-
@serialized_uploaders ||= {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def serialized_uploader?(column)
|
13
|
-
attribute_name = serialized_uploaders[column].to_s
|
14
|
-
serialized_uploaders.key?(column) && (serialized_attribute?(attribute_name) ||
|
15
|
-
hstore_attribute?(attribute_name) ||
|
16
|
-
json_attribute?(attribute_name))
|
17
|
-
|
9
|
+
@serialized_uploaders ||= read_from_superclass? ? superclass.serialized_uploaders : {}
|
18
10
|
end
|
19
11
|
|
20
|
-
def
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def hstore_attribute?(attribute)
|
25
|
-
columns_hash[attribute.to_s].type == :hstore
|
26
|
-
end
|
27
|
-
|
28
|
-
def json_attribute?(attribute)
|
29
|
-
columns_hash[attribute.to_s].type == :json
|
12
|
+
def serialized_uploader?(column)
|
13
|
+
serialized_uploaders.key?(column)
|
30
14
|
end
|
31
15
|
|
32
16
|
##
|
@@ -34,43 +18,53 @@ module CarrierWave
|
|
34
18
|
#
|
35
19
|
def mount_uploader(column, uploader=nil, options={}, &block)
|
36
20
|
super
|
37
|
-
|
21
|
+
|
38
22
|
serialize_to = options.delete :serialize_to
|
39
23
|
if serialize_to
|
40
|
-
|
24
|
+
serialization_column = options[:mount_on] || column
|
25
|
+
serialized_uploaders[serialization_column] = serialize_to
|
41
26
|
class_eval <<-RUBY, __FILE__, __LINE__+1
|
42
|
-
def #{
|
27
|
+
def #{serialization_column}_will_change!
|
43
28
|
#{serialize_to}_will_change!
|
44
|
-
@#{
|
29
|
+
@#{serialization_column}_changed = true
|
45
30
|
end
|
46
31
|
|
47
|
-
def #{
|
48
|
-
@#{
|
32
|
+
def #{serialization_column}_changed?
|
33
|
+
@#{serialization_column}_changed
|
49
34
|
end
|
50
35
|
RUBY
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
36
|
+
end
|
37
|
+
class_eval <<-RUBY, __FILE__, __LINE__+1
|
38
|
+
def write_uploader(column, identifier)
|
39
|
+
if self.class.serialized_uploader?(column)
|
40
|
+
serialized_field_name = self.class.serialized_uploaders[column].to_s
|
41
|
+
|
42
|
+
if serialized_field = self.send(serialized_field_name)
|
57
43
|
serialized_field[column.to_s] = identifier
|
58
44
|
else
|
59
|
-
|
45
|
+
self.send "\#{serialized_field_name}=", column.to_s => identifier
|
60
46
|
end
|
47
|
+
else
|
48
|
+
write_attribute(column, identifier)
|
61
49
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
50
|
+
end
|
51
|
+
|
52
|
+
def read_uploader(column)
|
53
|
+
if self.class.serialized_uploader?(column)
|
54
|
+
serialized_field = self.send self.class.serialized_uploaders[column]
|
55
|
+
serialized_field ? serialized_field[column.to_s] : nil
|
56
|
+
else
|
57
|
+
read_attribute(column)
|
70
58
|
end
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
end
|
60
|
+
RUBY
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def read_from_superclass?
|
67
|
+
superclass != ::ActiveRecord::Base && superclass.respond_to?(:serialized_uploaders)
|
74
68
|
end
|
75
69
|
end # Serializable
|
76
70
|
end # ActiveRecord
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-serializable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tima Maslyuchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '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
26
|
version: '0'
|
27
27
|
description: Carrierwave plugin that allow mount uploader to serialized field
|
@@ -31,7 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- Gemfile
|
36
36
|
- LICENSE.txt
|
37
37
|
- README.md
|
@@ -50,18 +50,19 @@ require_paths:
|
|
50
50
|
- lib
|
51
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.2.2
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Carrierwave plugin that allow mount uploader to serialized field
|
67
67
|
test_files: []
|
68
|
+
has_rdoc:
|