translated_attribute_value 0.0.2 → 0.0.2.1

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: 7512b92b1846fce309b74c318844f242b2134c1f
4
- data.tar.gz: 46d0e02b6a1dc4da4563cbec842ab7f48f18ebc4
3
+ metadata.gz: 032902799c2bf6bf02e8b6a6a41d6c2f2a92d47a
4
+ data.tar.gz: e77cfae303cef3461e03bc30ff09965931085625
5
5
  SHA512:
6
- metadata.gz: 58a03bc5142e696e41c25a0076aab8efee844032c3f9978fc23b5de0342be8500c88f69d7ef9a23543fa1efbc02ff432f7b6c783aa070de08f64f5be11ffbe2a
7
- data.tar.gz: 26fc9ce26e944b172786915bea34e155f2c4e7637dcb47fa48ae58cde0827afdbfe375556bdb12f9448e8695062494342647aabeecf3b9e32997f6e11967c378
6
+ metadata.gz: ea6f3d547f259019878255068cd0a368a40698f4306c9685426916e3a5f7eb7fc0741a3593312014d56212cd7aa5bb1262cbabc128a9ae517d9d671b46e86da5
7
+ data.tar.gz: c9954a1fe428e6c063e78afb327f2486a5afd0be0bda5f920ce94ece7785bdbca2694f4d8b0546bde86e6f566142762fe02a40db7130918c51eb3c6fa26c590a
@@ -1,3 +1,5 @@
1
+ require 'active_support/inflector'
2
+
1
3
  module TranslatedAttributeValue
2
4
  module Base
3
5
  def self.included(base)
@@ -10,17 +12,17 @@ module TranslatedAttributeValue
10
12
  if defined?(ActiveRecord::Base)
11
13
  self.send(:define_method, "#{attribute_name}_translated") do
12
14
  attribute_value = self.send(attribute_name)
13
- I18n.t("activerecord.attributes.user.#{attribute_name}_translation.#{attribute_value}")
15
+ I18n.t("activerecord.attributes.#{self.class.to_s.underscore}.#{attribute_name}_translation.#{attribute_value}")
14
16
  end
15
17
  elsif defined?(Mongoid::Document)
16
18
  self.send(:define_method, "#{attribute_name}_translated") do
17
19
  attribute_value = self.send(attribute_name)
18
- I18n.t("mongoid.attributes.user.#{attribute_name}_translation.#{attribute_value}")
20
+ I18n.t("mongoid.attributes.#{self.class.to_s.underscore}.#{attribute_name}_translation.#{attribute_value}")
19
21
  end
20
22
  else
21
23
  self.send(:define_method, "#{attribute_name}_translated") do
22
24
  attribute_value = self.send(attribute_name)
23
- I18n.t("translated_attribute_value.user.#{attribute_name}_translation.#{attribute_value}")
25
+ I18n.t("translated_attribute_value.#{self.class.to_s.underscore}.#{attribute_name}_translation.#{attribute_value}")
24
26
  end
25
27
  end
26
28
  end
@@ -1,3 +1,3 @@
1
1
  module TranslatedAttributeValue
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.2.1"
3
3
  end
@@ -5,6 +5,9 @@ describe TranslatedAttributeValue::Base do
5
5
  let(:test_model) { Class.new do
6
6
  include TranslatedAttributeValue::Base
7
7
  translated_value_for :status
8
+ def self.to_s
9
+ "NomeClasse"
10
+ end
8
11
  end.new
9
12
  }
10
13
 
@@ -21,7 +24,7 @@ describe TranslatedAttributeValue::Base do
21
24
 
22
25
  specify do
23
26
  test_model.stub(:status).and_return('my_value')
24
- expect(I18n).to receive(:t).with("activerecord.attributes.user.status_translation.my_value")
27
+ expect(I18n).to receive(:t).with("activerecord.attributes.nome_classe.status_translation.my_value")
25
28
  test_model.status_translated
26
29
  end
27
30
 
@@ -34,7 +37,7 @@ describe TranslatedAttributeValue::Base do
34
37
 
35
38
  specify do
36
39
  test_model.stub(:status).and_return('my_value')
37
- expect(I18n).to receive(:t).with("mongoid.attributes.user.status_translation.my_value")
40
+ expect(I18n).to receive(:t).with("mongoid.attributes.nome_classe.status_translation.my_value")
38
41
  test_model.status_translated
39
42
  end
40
43
 
@@ -46,7 +49,7 @@ describe TranslatedAttributeValue::Base do
46
49
 
47
50
  specify do
48
51
  test_model.stub(:status).and_return('my_value')
49
- expect(I18n).to receive(:t).with("translated_attribute_value.user.status_translation.my_value")
52
+ expect(I18n).to receive(:t).with("translated_attribute_value.nome_classe.status_translation.my_value")
50
53
  test_model.status_translated
51
54
  end
52
55
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translated_attribute_value
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinícius Oyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-02 00:00:00.000000000 Z
11
+ date: 2014-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails