weighable 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/weighable/model.rb +4 -1
- data/lib/weighable/version.rb +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: b27300c8013436a8e24bf525c1f4146d95805f6a
|
4
|
+
data.tar.gz: 42aebf7aaa52ec57e0b67aed44bf6230207fee78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78edf2c2c8733a61031947acd64fa55ab1fc95d66838c4896baf41dd5cc1cba00de0d6a4250cda474efc69de9bbc44971601aedc157e52a10bd8b27dfacbdf65
|
7
|
+
data.tar.gz: 7eea7a42375d276333f7b4cd5a8052dd04b09aea542f17286eff9ad8c8debea4895f0732085fa16de65905adb6b484a891383e9d87c2cf0fce623fdc239d99ba
|
data/lib/weighable/model.rb
CHANGED
@@ -9,7 +9,10 @@ module Weighable
|
|
9
9
|
define_method "#{column}=" do |weight|
|
10
10
|
weight = Weight.new(weight['value'], weight['unit']) if weight.is_a?(Hash)
|
11
11
|
original_unit = weight.try(:unit)
|
12
|
-
|
12
|
+
|
13
|
+
if original_unit && original_unit != Weight::UNIT[:unit]
|
14
|
+
weight = weight.try(:to, store_as)
|
15
|
+
end
|
13
16
|
|
14
17
|
public_send("#{column}_value=", weight.try(:value))
|
15
18
|
public_send("#{column}_unit=", weight.try(:unit))
|
data/lib/weighable/version.rb
CHANGED