attribute_enums 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,12 +81,7 @@ module AttributeEnums
81
81
 
82
82
  def _attribute_name_set_boolean_text_method
83
83
  if @_ae_i18n and defined?(::I18n)
84
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
85
- def #{_ae_text_method_name}
86
- return '' if read_attribute(:#{@_ae_attribute_name}).nil?
87
- I18n.translate('enums.%s%s.%s' % [self.class.send(:_ae_i18n_t_prefix), :#{@_ae_attribute_name}, read_attribute(:#{@_ae_attribute_name})])
88
- end
89
- RUBY
84
+ _attribute_name_set_text_method_with_i18n
90
85
  else
91
86
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
92
87
  def #{_ae_text_method_name}
@@ -99,12 +94,7 @@ module AttributeEnums
99
94
 
100
95
  def _attribute_name_set_string_text_method
101
96
  if @_ae_i18n and defined?(::I18n)
102
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
103
- def #{_ae_text_method_name}
104
- return '' if read_attribute(:#{@_ae_attribute_name}).nil?
105
- I18n.translate('enums.%s%s.%s' % [self.class.send(:_ae_i18n_t_prefix), :#{@_ae_attribute_name}, read_attribute(:#{@_ae_attribute_name})])
106
- end
107
- RUBY
97
+ _attribute_name_set_text_method_with_i18n
108
98
  else
109
99
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
110
100
  def #{_ae_text_method_name}
@@ -115,6 +105,20 @@ module AttributeEnums
115
105
  end
116
106
  end
117
107
 
108
+ def _attribute_name_set_text_method_with_i18n
109
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
110
+ def #{_ae_text_method_name}
111
+ return '' if read_attribute(:#{@_ae_attribute_name}).nil?
112
+ t_str = 'enums.'
113
+ t_str << '#{_ae_i18n_t_prefix}'
114
+ t_str << '#{@_ae_attribute_name}'
115
+ t_str << '.'
116
+ t_str << read_attribute(:#{@_ae_attribute_name}).to_s
117
+ I18n.translate(t_str)
118
+ end
119
+ RUBY
120
+ end
121
+
118
122
  end
119
123
  end
120
124
 
@@ -1,4 +1,4 @@
1
1
  module AttributeEnums
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribute_enums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-08 00:00:00.000000000 Z
12
+ date: 2013-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord