uploadbox 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f08638e9f1603367e279ce8a511d2c1d145ce038
4
- data.tar.gz: 77e23362af2e4a451212c183578a9e748136ba69
3
+ metadata.gz: 2cd9ffc10b1b04716b72d5e9d6cce5d27aecface
4
+ data.tar.gz: 35031ae75f3b06e2c93464f09fc3aa0d28a28c4b
5
5
  SHA512:
6
- metadata.gz: 956015e0fe26df3ebddbf7d086d2640d405e597768db74c2da4119d7e8517ec88156230095840638c0e9af6b5f06101001ad8f94b5b6947f5cdd3296d0a10f05
7
- data.tar.gz: 4215098324e2e7290cc6c29a2823c7cdd985143babbab507cc3667b3fa2c0f497d5cf70cd560ab514884960f025447c308147f271a69a94dc129e3bd917c5804
6
+ metadata.gz: cc0454c5266b6326bc621aaa233b36e90a8678eac2e2c5152ddc2f9d3d5f8391fbc7e3f4b50af6db4b53052b5517c144ad8ba142b0bb591e9c2557a6636220ab
7
+ data.tar.gz: 8bf0b98de0cca562eae800260c20a44649c6983ae1c194326c43eca2850833abc2e6d8c260803b749de7d7262edd679908fcf0ecaa68eab0c3476a2e4b2c05e5
@@ -20,7 +20,7 @@ module Uploadbox
20
20
  Uploadbox.const_set(upload_class_name, upload_class)
21
21
 
22
22
  # @post.picture?
23
- define_method("#{upload_name}?") do
23
+ define_method("#{upload_name}?") do
24
24
  upload = send("#{upload_name}_upload")
25
25
  upload and upload.file?
26
26
  end
@@ -117,8 +117,8 @@ module Uploadbox
117
117
 
118
118
  end
119
119
 
120
- has_one "#{upload_name}_upload".to_sym, as: :imageable,
121
- class_name: "Uploadbox::#{self.to_s + upload_name.to_s.camelize}",
120
+ has_one "#{upload_name}_upload".to_sym, as: :imageable,
121
+ class_name: "Uploadbox::#{self.to_s + upload_name.to_s.camelize}",
122
122
  autosave: true
123
123
  accepts_nested_attributes_for "#{upload_name}_upload".to_sym
124
124
  end
@@ -139,12 +139,12 @@ module Uploadbox
139
139
  imageable_type = self.to_s
140
140
  upload_class_name = imageable_type + upload_name.to_s.camelize
141
141
  upload_class = Class.new(Image)
142
-
142
+
143
143
  Uploadbox.instance_eval {remove_const upload_class_name} if Uploadbox.const_defined?(upload_class_name)
144
144
  Uploadbox.const_set(upload_class_name, upload_class)
145
145
 
146
146
  # @post.images?
147
- define_method("#{upload_name}?") do
147
+ define_method("#{upload_name}?") do
148
148
  upload = send(upload_name)
149
149
  upload and upload.any?
150
150
  end
@@ -157,6 +157,19 @@ module Uploadbox
157
157
  end
158
158
  end
159
159
 
160
+ # @post.picture=(id)
161
+ define_method("#{upload_name}=") do |upload_id|
162
+ if upload_id.present?
163
+ self.send("#{upload_name}_upload=", upload_class.find(upload_id))
164
+ end
165
+ end
166
+
167
+ # @post.add_remote_image_url('http://exemple.com/image.jpg')
168
+ define_method("add_remote_#{upload_name.to_s.singularize}_url") do |url|
169
+ upload = upload_class.create!(remote_file_url: url)
170
+ self.send(upload_name).send('<<', upload)
171
+ end
172
+
160
173
  # Post.update_images_versions!
161
174
  self.define_singleton_method "update_#{upload_name}_versions!" do
162
175
  Uploadbox.const_get(upload_class_name).find_each{|upload| upload.file.recreate_versions!}
@@ -1,3 +1,3 @@
1
1
  module Uploadbox
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio Protzek