dis 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dis/model.rb +11 -3
- data/lib/dis/model/data.rb +1 -1
- data/lib/dis/validations/data_presence.rb +1 -1
- data/lib/dis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 769e16af4437ba86e74fcae272a4e7d893737cc1
|
4
|
+
data.tar.gz: 64330af5cd3172d8f94804391bbbab85c8f87435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361ec8faf76e47ba5bb8185e4d34ea8f30667d395aee2530cf4956e021d3925d8f8196228506bfaa0080ef0a60d429f6915ceb67560be8cdde61e689749f3eb7
|
7
|
+
data.tar.gz: 0edc37ad592b0c61c01ff984b801e954472913b716d74d78f1556cfb23845d78600c64d0a925a8cd53cd205f582e52e6cf66a993677df93901111da0f33a432e
|
data/lib/dis/model.rb
CHANGED
@@ -100,11 +100,15 @@ module Dis
|
|
100
100
|
|
101
101
|
# Assigns new data. This also sets <tt>content_length</tt>, and resets
|
102
102
|
# <tt>content_hash</tt> to nil.
|
103
|
-
def data=(
|
104
|
-
new_data = Dis::Model::Data.new(self,
|
103
|
+
def data=(raw_data)
|
104
|
+
new_data = Dis::Model::Data.new(self, raw_data)
|
105
105
|
attribute_will_change!('data') unless new_data == dis_data
|
106
106
|
@dis_data = new_data
|
107
|
-
dis_set :content_hash, nil
|
107
|
+
dis_set :content_hash, if raw_data.nil?
|
108
|
+
nil
|
109
|
+
else
|
110
|
+
Storage.file_digest(new_data.read)
|
111
|
+
end
|
108
112
|
dis_set :content_length, dis_data.content_length
|
109
113
|
end
|
110
114
|
|
@@ -113,6 +117,10 @@ module Dis
|
|
113
117
|
changes.include?('data')
|
114
118
|
end
|
115
119
|
|
120
|
+
def dis_stored?
|
121
|
+
!(new_record? || data_changed?)
|
122
|
+
end
|
123
|
+
|
116
124
|
# Assigns new data from an uploaded file. In addition to the actions
|
117
125
|
# performed by <tt>data=</tt>, this will set <tt>content_type</tt> and
|
118
126
|
# <tt>filename</tt>.
|
data/lib/dis/model/data.rb
CHANGED
@@ -8,7 +8,7 @@ module Dis
|
|
8
8
|
# Validates that a record has data, either freshly assigned or
|
9
9
|
# persisted in the storage. Adds a `:blank` error on `:data`if not.
|
10
10
|
def validate(record)
|
11
|
-
record.errors.add(:data, :blank)
|
11
|
+
record.errors.add(:data, :blank) if !record.data? || record.data.blank?
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/dis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|