serial_translator 0.0.2 → 0.0.3
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 +4 -4
- data/.travis.yml +1 -1
- data/Rakefile +5 -0
- data/lib/serial_translator.rb +5 -1
- data/lib/serial_translator/version.rb +1 -1
- data/spec/lib/serial_translator_spec.rb +14 -0
- 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: bd4d2cf24fa2a993a3ca81f41d10c809a2d8e3af
|
4
|
+
data.tar.gz: f4f8e3a631db7ca33d30bf1379599bae0732394b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a508e0d3ff34d9dd91134b35de20f9441dcc12c9057ee05cbd4379bc9861489678b3a79e90fee7feb418d6c64d31bfc4895edf4bf47b764fe35956edbfeab53
|
7
|
+
data.tar.gz: b95fd270b3e37a5dd4eac91b7a4d98de009da1513e50d3e17893d624a9df1a26c9d9e0c980c0cbdf66f90cce8e2e6f39569dfb3b589b36847adc836996d18ae4
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/lib/serial_translator.rb
CHANGED
@@ -28,7 +28,11 @@ module SerialTranslator
|
|
28
28
|
|
29
29
|
define_method "#{attribute}=" do |value|
|
30
30
|
translations = translations_for(attribute)
|
31
|
-
|
31
|
+
if value.present?
|
32
|
+
translations[current_translation_locale] = value
|
33
|
+
else
|
34
|
+
translations.delete(current_translation_locale)
|
35
|
+
end
|
32
36
|
__send__(:"#{attribute}_translations=", translations)
|
33
37
|
end
|
34
38
|
end
|
@@ -42,6 +42,20 @@ describe SerialTranslator do
|
|
42
42
|
object.title = 'Deutsch'
|
43
43
|
object.title_translations.should eq({ de: 'Deutsch' })
|
44
44
|
end
|
45
|
+
|
46
|
+
it 'nil removes the value for the current text locale' do
|
47
|
+
object.title_translations = { de: 'Deutsch' }
|
48
|
+
object.current_translation_locale = :de
|
49
|
+
object.title = nil
|
50
|
+
object.title_translations.should eq({})
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'blank string removes the value for the current text locale' do
|
54
|
+
object.title_translations = { de: 'Deutsch' }
|
55
|
+
object.current_translation_locale = :de
|
56
|
+
object.title = " "
|
57
|
+
object.title_translations.should eq({})
|
58
|
+
end
|
45
59
|
end
|
46
60
|
|
47
61
|
describe '#current_translation_locale' do
|