attribute_localizer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/attribute_localizer.rb +19 -0
- metadata +3 -3
data/lib/attribute_localizer.rb
CHANGED
@@ -24,9 +24,27 @@ module AttributeLocalizer
|
|
24
24
|
module_eval src, __FILE__, __LINE__
|
25
25
|
|
26
26
|
src = <<-end_src
|
27
|
+
|
28
|
+
def as_json(options = {})
|
29
|
+
instance_values
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_json(options = {})
|
34
|
+
instance_values
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
27
38
|
def locale
|
28
39
|
@locale || I18n.locale
|
29
40
|
end
|
41
|
+
|
42
|
+
def instance_values
|
43
|
+
values = super
|
44
|
+
values['attributes'].merge!(#{attributes.map { |attribute| "'#{attribute}' => #{attribute}" }.join(', ') })
|
45
|
+
values
|
46
|
+
end
|
47
|
+
|
30
48
|
end_src
|
31
49
|
|
32
50
|
module_eval src, __FILE__, __LINE__
|
@@ -67,6 +85,7 @@ module AttributeLocalizer
|
|
67
85
|
klass.send :private, 'write_locale_data'
|
68
86
|
|
69
87
|
src = <<-end_src
|
88
|
+
|
70
89
|
private
|
71
90
|
def localization_hash_key
|
72
91
|
"_\#{id}".to_sym
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Deering
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-21 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|