echo_uploads 0.0.21 → 0.0.22

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: 9eb0b18883124323021f98c434e54d7d45af33e6
4
- data.tar.gz: 8b6483eae3518bff8fba10b9db17345885390d95
3
+ metadata.gz: ab518cb10d7eba1c95a48a067e4bb86d923e143b
4
+ data.tar.gz: a180ec2f68fd32cf759c28975acc1c362106c294
5
5
  SHA512:
6
- metadata.gz: 74957ac12010f4856506b72245700790365910ce2540ae4b3c3a71f8aad31f9ac40fc8f23d72b8e93ab93d4e3006b4a53d3170ef5b2c9d8908decc0eb50fb979
7
- data.tar.gz: ebfd69b627b3bbabc93e205f8f2d492c8612c39814ef596fc2cd9e6634108954a61fa3b20017e6818b3e801061bf7bd77b11383dd5ed36fb323cce94d1a0ce09
6
+ metadata.gz: dd6a3b2988b4bd5599583c76d58c6a9540d77c514be8386b78d9a8d53bf7a92868ca1b984f001468ee0c1ac827c7feaf79290f4a77be3286494b46e3ecd8d56d
7
+ data.tar.gz: 34460a5a568fc04096fdd77ebae11baf02e0837ae486f1fbc36a64d39bf23051222bce489de15be73d1e86ab09b79146899bc1355028b5a8d3dd5adc5163240b
@@ -120,11 +120,17 @@ module EchoUploads
120
120
  self.echo_uploads_config = echo_uploads_config.merge attr => {}
121
121
 
122
122
  # Define reader method for the file attribute.
123
- attr_reader attr
124
-
125
- # Define the writer method for the file attribute.
126
- define_method("#{attr}=") do |file|
127
- if options[:map]
123
+ if Rails::VERSION::MAJOR >= 5
124
+ attribute attr
125
+ else
126
+ attr_reader attr
127
+ end
128
+
129
+ # Define the accessor methods for the mapped version(s) of the file. Returns
130
+ # an array.
131
+ define_method("mapped_#{attr}") do
132
+ unless instance_variable_get("@mapped_#{attr}")
133
+ file = send attr
128
134
  mapper = ::EchoUploads::Mapper.new file
129
135
  if options[:map].is_a? Proc
130
136
  options[:map].call file, mapper
@@ -133,21 +139,11 @@ module EchoUploads
133
139
  end
134
140
  # Write an array of ActionDispatch::Http::UploadedFile objects to the instance
135
141
  # variable.
136
- send "mapped_#{attr}=", mapper.outputs
142
+ instance_variable_set("@mapped_#{attr}", mapper.outputs)
137
143
  end
138
-
139
- if attr
140
- # Mark as dirty.
141
- attribute_will_change! attr
142
- end
143
-
144
- instance_variable_set "@#{attr}", file
144
+ instance_variable_get("@mapped_#{attr}")
145
145
  end
146
146
 
147
- # Define the accessor methods for the mapped version(s) of the file. Returns
148
- # an array.
149
- attr_accessor "mapped_#{attr}"
150
-
151
147
  # Define the original filename method.
152
148
  define_method("#{attr}_original_filename") do
153
149
  echo_uploads_map_metadata(attr, options, &:original_filename)
@@ -1,3 +1,3 @@
1
1
  module EchoUploads
2
- VERSION = '0.0.21'
2
+ VERSION = '0.0.22'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: echo_uploads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrett Colby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.2.2
84
+ rubygems_version: 2.6.8
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Uploaded files for Rails