acts_as_localized 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cdd5e0db66bba1dca59e9c6e855781b4a7d72ea
4
- data.tar.gz: bd6fd761d5a83ed38c452d2522f670ddc13f1f99
3
+ metadata.gz: 03d61b9843674dc73d603215b8595f16c34cef00
4
+ data.tar.gz: ceb2d206e9c899cfbcf188004a43bd8708d1ae85
5
5
  SHA512:
6
- metadata.gz: 8d57a97cefac3576c5d806c14786b05a1530920d9f22fd2f7aac5658248ec7acc9f8243c80d1b510430ab671b2c58f6a42dfef898c64a1f8b23bbc4510c5ae08
7
- data.tar.gz: 2f33bf32d46348912f49d278dfce4d9d5a125f9730ffb70b1d6b014662e5bed67915e72db97cbb1f26d825cf513a9a9cd994e1019d9a27e6a9fdbec275ace76a
6
+ metadata.gz: ee7b554bba7285bc51eab0d366c176e9e1e561c6e773b8b5283293a0f8fe53af05a0d4d4e9127fd96f1ebde4ef35cee337d609845cbc22373e86f8ea61ca9a98
7
+ data.tar.gz: d3c8acc428ecf1cd1f775b3bc8f678b1c9d75ab693cafcc6c70fa2ca833a2dda62f4a137dd22ba4c1d8ac69fb2e7bbc7da3fe849991aa45e35cc231843a6d513
data/README.md CHANGED
@@ -25,9 +25,12 @@ picture = Picture.create!(
25
25
  )
26
26
 
27
27
  I18n.locale = :en
28
- picture.title # => Title EN
28
+ picture.title #=> Title EN
29
+ picture.title = 'Updated Title EN' # same as `picture.title_en=`
30
+
29
31
  I18n.locale = :fr
30
32
  picture.title # => Title FR
33
+ picture.title = 'Updated Title EN' # same as `picture.title_fr=`
31
34
  ```
32
35
 
33
36
  ---
@@ -14,6 +14,9 @@ module ActsAsLocalized
14
14
  define_method attribute do
15
15
  send("#{attribute}_#{I18n.locale}")
16
16
  end
17
+ define_method "#{attribute}=" do |value|
18
+ send("#{attribute}_#{I18n.locale}=", value)
19
+ end
17
20
  end
18
21
  end
19
22
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsLocalized
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -50,7 +50,7 @@ class ActsAsLocalizedTest < MiniTest::Test
50
50
  teardown_db
51
51
  end
52
52
 
53
- def test_localization
53
+ def test_reader
54
54
  model = TestModel.create!(
55
55
  :attr_en => 'content EN',
56
56
  :attr_fr => 'content FR'
@@ -67,4 +67,24 @@ class ActsAsLocalizedTest < MiniTest::Test
67
67
  end
68
68
  end
69
69
 
70
+ def test_writer
71
+ model = TestModel.create!(
72
+ :attr => 'content EN'
73
+ )
74
+ assert_equal 'content EN', model.attr
75
+ assert_equal 'content EN', model.attr_en
76
+ assert_equal nil, model.attr_fr
77
+
78
+ I18n.locale = :fr
79
+ model.update_attribute(:attr, 'content FR')
80
+ assert_equal 'content FR', model.attr_fr
81
+
82
+ begin
83
+ I18n.locale = :invalid
84
+ model.attr = 'invalid'
85
+ rescue => e
86
+ assert e.is_a?(NoMethodError)
87
+ end
88
+ end
89
+
70
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_localized
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Khabarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2015-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord