shrine-reform 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -5
- data/lib/shrine/plugins/reform.rb +17 -11
- data/shrine-reform.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27a8fdd87a1f63696f2738360f6ba77862db4f3e
|
4
|
+
data.tar.gz: de85b092c1111cc8ef4df702eef64658adff38b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 223536a013b503893ec801748763725d2f3804b889a9ceee87da3672ab173650ffbfafea8f0eaa9065c963febf77a7adc015d0494107592ada5634e109605f20
|
7
|
+
data.tar.gz: 76edc07d55be8e16517e6c84ce3d174d2537681ebd2d47f2e5fbfec2418fccbac1c6456d7260df644425e301d6fdeb61fbe962e800e96a0780a0b5e19945bbb4
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ gem "shrine", github: "janko-m/shrine"
|
|
11
11
|
|
12
12
|
## Usage
|
13
13
|
|
14
|
-
The reform plugin can be loaded globally alongside
|
14
|
+
The reform plugin can be loaded globally alongside activerecord plugin.
|
15
15
|
|
16
16
|
```rb
|
17
17
|
Shrine.plugin :activerecord
|
@@ -24,13 +24,10 @@ end
|
|
24
24
|
```
|
25
25
|
```rb
|
26
26
|
class PostForm < Reform::Form
|
27
|
-
|
27
|
+
include ImageUploader[:image]
|
28
28
|
end
|
29
29
|
```
|
30
30
|
|
31
|
-
Notice that the only difference from ActiveRecord is that a Reform attachment
|
32
|
-
module has to be *prepended* instead of included.
|
33
|
-
|
34
31
|
## License
|
35
32
|
|
36
33
|
[MIT](LICENSE.txt)
|
@@ -8,11 +8,19 @@ class Shrine
|
|
8
8
|
super
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def included(form)
|
12
12
|
super
|
13
13
|
|
14
14
|
return unless form < ::Reform::Form
|
15
15
|
|
16
|
+
properties = [
|
17
|
+
:"#{@name}",
|
18
|
+
:"#{@name}_remote_url",
|
19
|
+
:"#{@name}_data_uri",
|
20
|
+
:"remove_#{@name}",
|
21
|
+
:"cached_#{@name}_data",
|
22
|
+
]
|
23
|
+
|
16
24
|
module_eval <<-RUBY, __FILE__, __LINE__ + 1
|
17
25
|
def prepopulate!(*)
|
18
26
|
super
|
@@ -26,7 +34,11 @@ class Shrine
|
|
26
34
|
RUBY
|
27
35
|
|
28
36
|
form.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
29
|
-
|
37
|
+
def self.create_accessors(name, definition)
|
38
|
+
return if #{properties}.include?(name)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
30
42
|
attr_accessor :#{@name}_data
|
31
43
|
|
32
44
|
validate do
|
@@ -36,15 +48,9 @@ class Shrine
|
|
36
48
|
end
|
37
49
|
RUBY
|
38
50
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
form.send(:property, :"cached_#{@name}_data", virtual: true) if instance_methods.include?(:"cached_#{@name}_data")
|
43
|
-
end
|
44
|
-
|
45
|
-
def included(form)
|
46
|
-
super
|
47
|
-
raise Error, "Reform attachment modules have to be prepended instead of included" if form < ::Reform::Form
|
51
|
+
(properties & instance_methods).each do |name|
|
52
|
+
form.send(:property, name, virtual: true)
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
data/shrine-reform.gemspec
CHANGED