attribute_enums 0.1.8 → 0.2.0

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.
Files changed (66) hide show
  1. data/.gitignore +1 -3
  2. data/.rspec +1 -0
  3. data/CHANGELOG +4 -0
  4. data/Gemfile +1 -1
  5. data/README.markdown +61 -59
  6. data/attribute_enums.gemspec +5 -16
  7. data/lib/attribute_enums.rb +0 -4
  8. data/lib/attribute_enums/active_record.rb +122 -0
  9. data/lib/attribute_enums/common.rb +168 -0
  10. data/lib/attribute_enums/railtie.rb +2 -2
  11. data/lib/attribute_enums/version.rb +1 -1
  12. data/spec/common_and_active_record/ask_methods_options_spec.rb +58 -0
  13. data/spec/common_and_active_record/attribute_name_spec.rb +7 -0
  14. data/spec/common_and_active_record/boolean_options_spec.rb +43 -0
  15. data/spec/common_and_active_record/default_options_spec.rb +77 -0
  16. data/spec/common_and_active_record/i18n_options_spec.rb +116 -0
  17. data/spec/common_and_active_record/in_options_spec.rb +38 -0
  18. data/spec/common_and_active_record/readme_user_example_spec.rb +87 -0
  19. data/spec/common_and_active_record/scopeds_options_spec.rb +114 -0
  20. data/spec/common_and_active_record/validate_options_spec.rb +82 -0
  21. data/spec/spec_helper.rb +5 -12
  22. data/spec/support/locales/person_en.yml +14 -0
  23. data/spec/support/locales/person_zh-CN.yml +14 -0
  24. data/spec/support/locales/user_en.yml +7 -15
  25. data/spec/support/models/person.rb +23 -0
  26. metadata +34 -229
  27. data/Guardfile +0 -22
  28. data/lib/attribute_enums/active_record_extension.rb +0 -88
  29. data/spec/models/active_record/user_spec.rb +0 -67
  30. data/spec/rails3_0_app/.gitignore +0 -4
  31. data/spec/rails3_0_app/.rspec +0 -1
  32. data/spec/rails3_0_app/Gemfile +0 -13
  33. data/spec/rails3_0_app/Rakefile +0 -7
  34. data/spec/rails3_0_app/app/controllers/application_controller.rb +0 -3
  35. data/spec/rails3_0_app/app/helpers/application_helper.rb +0 -2
  36. data/spec/rails3_0_app/app/models/user.rb +0 -2
  37. data/spec/rails3_0_app/app/views/layouts/application.html.erb +0 -14
  38. data/spec/rails3_0_app/config.ru +0 -4
  39. data/spec/rails3_0_app/config/application.rb +0 -44
  40. data/spec/rails3_0_app/config/boot.rb +0 -6
  41. data/spec/rails3_0_app/config/database.yml +0 -19
  42. data/spec/rails3_0_app/config/environment.rb +0 -6
  43. data/spec/rails3_0_app/config/environments/development.rb +0 -26
  44. data/spec/rails3_0_app/config/environments/production.rb +0 -49
  45. data/spec/rails3_0_app/config/environments/test.rb +0 -35
  46. data/spec/rails3_0_app/config/initializers/backtrace_silencers.rb +0 -7
  47. data/spec/rails3_0_app/config/initializers/inflections.rb +0 -10
  48. data/spec/rails3_0_app/config/initializers/mime_types.rb +0 -5
  49. data/spec/rails3_0_app/config/initializers/secret_token.rb +0 -7
  50. data/spec/rails3_0_app/config/initializers/session_store.rb +0 -8
  51. data/spec/rails3_0_app/config/locales/en.yml +0 -5
  52. data/spec/rails3_0_app/config/routes.rb +0 -58
  53. data/spec/rails3_0_app/db/migrate/20111129011508_create_users.rb +0 -14
  54. data/spec/rails3_0_app/db/schema.rb +0 -23
  55. data/spec/rails3_0_app/db/seeds.rb +0 -7
  56. data/spec/rails3_0_app/lib/tasks/.gitkeep +0 -0
  57. data/spec/rails3_0_app/public/404.html +0 -26
  58. data/spec/rails3_0_app/public/422.html +0 -26
  59. data/spec/rails3_0_app/public/500.html +0 -26
  60. data/spec/rails3_0_app/public/favicon.ico +0 -0
  61. data/spec/rails3_0_app/public/images/rails.png +0 -0
  62. data/spec/rails3_0_app/public/index.html +0 -239
  63. data/spec/rails3_0_app/public/robots.txt +0 -5
  64. data/spec/rails3_0_app/public/stylesheets/.gitkeep +0 -0
  65. data/spec/rails3_0_app/script/rails +0 -6
  66. data/spec/rails3_0_app/vendor/plugins/.gitkeep +0 -0
data/.gitignore CHANGED
@@ -2,8 +2,6 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .rvmrc
5
6
 
6
7
 
7
- spec/rails3_0_app/db/*.sqlite3
8
- spec/rails3_0_app/log/*
9
- spec/rails3_0_app/tmp/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.0
2
+
3
+ * refactoring options
4
+
1
5
  == 0.1.8
2
6
 
3
7
  * fix 'DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically.'
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "http://ruby.taobao.org"
2
2
 
3
3
  # Specify your gem's dependencies in attribute_enums.gemspec
4
4
  gemspec
data/README.markdown CHANGED
@@ -1,14 +1,14 @@
1
1
  #AttributeEnums
2
2
 
3
- AttributeEnums is a model attribute enums plugin for Rails3. like 'symbolize' gem.
3
+ AttributeEnums is a model attribute enums plugin for Rails3.
4
4
 
5
5
  * https://github.com/vkill/attribute_enums
6
6
 
7
7
  ##Supported versions
8
8
 
9
- * Ruby 1.8.7, 1.9.2, 1.9.3
9
+ * Ruby 1.9
10
10
 
11
- * Rails 3.0.x, 3.1
11
+ * Rails 3
12
12
 
13
13
 
14
14
  ##Installation
@@ -17,9 +17,11 @@ In your app's `Gemfile`, add:
17
17
 
18
18
  gem "attribute_enums"
19
19
 
20
- Then run:
20
+ or
21
21
 
22
- > bundle
22
+ gem "attribute_enums", require: "attribute_enums/active_record"
23
+ #app/models/xxx.rb
24
+ include ::AttributeEnums::ActiveRecord
23
25
 
24
26
 
25
27
  ##Usage Example
@@ -41,94 +43,94 @@ Then run:
41
43
 
42
44
  #app/models/user.rb
43
45
  class User < ActiveRecord::Basse
44
- attribute_enums :gender, :in => [:female, :male]
45
- attribute_enums :enable, :booleans => true
46
+ attribute_enums :gender, in: [:female, :male], default: :male, scopeds: true, ask_methods: true, i18n: true, validate: true
47
+ attribute_enums :enable, boolean: true, default: true, scopeds: :disable, i18n: {t_prefix: :person_}
46
48
  end
47
49
 
50
+ # in config/locales/enums_en.yml
51
+ en:
52
+ enums:
53
+ gender:
54
+ female: Girl
55
+ male: Boy
56
+ enable:
57
+ "true": "Enable"
58
+ "false": "Disable"
59
+ person_gender:
60
+ female: Girl
61
+ male: Boy
62
+ person_enable:
63
+ "true": "Enable"
64
+ "false": "Disable"
48
65
 
49
66
  ##Options
50
67
 
51
- ###booleans
68
+ ###in or boolean
52
69
 
53
- default `false`
70
+ if use 'boolean', auto ignore 'in'.
54
71
 
55
- if use this, please don't use `in/within`.
72
+ this option generate get_attr_values and attr_text methods
56
73
 
57
- ###in/within
58
-
59
- default `[]`
74
+ #active_record
75
+ User.get_gender_values
76
+ User.get_enable_values
77
+ user = User.new(gender: :male, enable: true)
78
+ user.gender_text
79
+ user.enable_text
60
80
 
61
- if use this, please don't use `booleans`.
81
+ you can use get_attr_values on rails `select` helper and more.
62
82
 
63
83
  ###i18n and use example
64
84
 
65
- default `true`
85
+ default `false`
66
86
 
67
- # in config/locales/enums_en.yml
68
- en:
69
- activerecord:
70
- models:
71
- user: User
72
- attributes:
73
- user:
74
- gender: Gender
75
- enable: Enable
76
- enums:
77
- user:
78
- gender:
79
- female: Girl
80
- male: Boy
81
- enable:
82
- "true": "Yes"
83
- "false": "No"
87
+ set `true`, i18n is valid get_attr_values and attr_text methods.
88
+
89
+ #active_record
90
+ User.get_gender_values #=> [["Girl", "female"], ["Boy", "male"]]
91
+ User.get_enable_values #=> [["Enable", true], ["Disable", false]]
92
+ user = User.new(gender: :male, enable: true)
93
+ user.gender_text #=> "Boy"
94
+ user.enable_text #=> "Enable"
84
95
 
85
96
  ###scopes and use example
86
97
 
87
- default `true`
98
+ default `false`
88
99
 
89
100
  #active_record
90
- User.male => User.where(:gender => :male)
91
- User.female => User.where(:gender => :female)
92
- User.enable => User.where(:enable => true)
93
- User.not_enable => User.where(:enable => false)
101
+ User.male #=> User.where(gender: :male)
102
+ User.female #=> User.where(gender: :female)
103
+ User.enable #=> User.where(enable: true)
104
+ User.disable #=> User.where(enable: false)
94
105
 
95
106
  ###validate
96
107
 
97
- default `true`
108
+ default `false`, it only support `in` option.
98
109
 
99
- ###allow_blank
110
+ if you want support attribute value is nil, you can use `validate: {allow_nil: true}`
100
111
 
101
- default `false`, is valid with validate == true and in/within == true
112
+ ###ask_methods and use example
102
113
 
103
- ###methods and use example
104
-
105
- default `true`
114
+ default `false`, it only support `in` option.
106
115
 
107
116
  #active_record
108
- User.get_gender_values => [["female", "Girl"], ["male", "Boy"]]
109
- User.gender_values => {"female"=>"Girl", "male"=>"Boy"}
110
- User.get_enable_values => [[true, "Yes"], [false, "No"]]
111
- User.enable_values => {true=>"Yes", false=>"No"}
112
- user = User.create(:gender => :male, :enable => true)
113
- user.gender_text => "Boy"
114
- user.enable_text => "Yes"
115
- user.male? => true
116
- user.female? => false
117
- user.enable => true
117
+ user = User.new(gender: :male, enable: true)
118
+ user.male? #=> true
119
+ user.female? #=> false
118
120
 
119
121
  ###default
120
122
 
121
123
  if your defined `default`, it set attribute `default` value before validate.
122
124
 
123
- Note: if your migration defined field default, this is invalidation.
124
-
125
-
126
- ##Run test for development
125
+ #active_record
126
+ user = User.new
127
+ user.valid?
128
+ user.gender #=> :male
127
129
 
128
- > guard
130
+ Note: if your migration defined field default, this is invalidation.
129
131
 
130
132
 
131
133
  ##Copyright
132
134
 
133
- Copyright (c) 2011 vkill.net .
135
+ Copyright (c) 2011-2013 vkill.net .
134
136
 
@@ -18,20 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_development_dependency 'bundler'
22
- s.add_development_dependency "rake"
23
- s.add_development_dependency "rspec"
24
- s.add_development_dependency "guard-rspec"
25
-
26
- s.add_development_dependency "rails", "~> 3.0"
27
- s.add_development_dependency "sqlite3-ruby"
28
- s.add_development_dependency "rspec-rails", "~> 2.7.0"
29
- s.add_development_dependency "capybara"
30
- s.add_development_dependency "timecop"
31
- s.add_development_dependency "pry"
32
- s.add_development_dependency "pry-padrino"
33
-
34
- s.add_dependency "activerecord", "~> 3.0"
35
- s.add_dependency "activesupport", "~> 3.0"
21
+ s.add_development_dependency "activerecord"
22
+ s.add_development_dependency "sqlite3"
23
+ s.add_development_dependency "i18n"
24
+ s.add_development_dependency "rspec-rails", '~> 2.13.0'
25
+
36
26
  end
37
-
@@ -1,7 +1,3 @@
1
- require "active_support/concern"
2
- require "active_support/core_ext/object"
3
- require "active_support/core_ext/class/attribute_accessors"
4
-
5
1
  require "attribute_enums/version"
6
2
 
7
3
  if defined?(::Rails)
@@ -0,0 +1,122 @@
1
+ module AttributeEnums
2
+ end
3
+
4
+ require "attribute_enums/version"
5
+ require "attribute_enums/common"
6
+
7
+ module AttributeEnums
8
+ module ActiveRecord
9
+
10
+ def self.included base
11
+ base.extend(ClassMethods)
12
+ base.extend(AttributeEnums::Common)
13
+ end
14
+
15
+ module ClassMethods
16
+
17
+ private
18
+
19
+ def _ae_set_default
20
+ set_defaule_method_name = "set_defaule_#{@_ae_attribute_name}"
21
+ if @_ae_boolean
22
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
23
+ def #{set_defaule_method_name}
24
+ write_attribute(:#{@_ae_attribute_name}, #{@_ae_default}) if read_attribute(:#{@_ae_attribute_name}).nil?
25
+ end
26
+ RUBY
27
+ else
28
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
29
+ def #{set_defaule_method_name}
30
+ write_attribute(:#{@_ae_attribute_name}, :#{@_ae_default}) if read_attribute(:#{@_ae_attribute_name}).nil?
31
+ end
32
+ RUBY
33
+ end
34
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
35
+ before_validation :#{set_defaule_method_name}
36
+ RUBY
37
+ end
38
+
39
+ def _ae_set_string_ask_methods
40
+ @_ae_in.each do |_in|
41
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
42
+ def #{_ae_ask_methods_string_attribute_method_name(_in)}
43
+ read_attribute(:#{@_ae_attribute_name}).to_s == '#{_in}'
44
+ end
45
+ RUBY
46
+ end
47
+ end
48
+
49
+ def _ae_set_string_scopeds
50
+ @_ae_in.each do |_in|
51
+ # scope _ae_scopeds_string_attribute_method_name(_in), ->{ where(@_ae_attribute_name => _in) }
52
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
53
+ scope :#{_ae_scopeds_string_attribute_method_name(_in)}, ->{ where(:#{@_ae_attribute_name} => :#{_in}) }
54
+ RUBY
55
+ end
56
+ end
57
+
58
+ def _ae_set_boolean_scopeds
59
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
60
+ scope :#{@_ae_attribute_name}, ->{ where(:#{@_ae_attribute_name} => true) }
61
+ RUBY
62
+ if @_ae_scopeds.is_a?(Symbol)
63
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
64
+ scope :#{@_ae_scopeds}, ->{ where(:#{@_ae_attribute_name} => false) }
65
+ RUBY
66
+ puts "scope :#{@_ae_scopeds}, ->{ where(:#{@_ae_attribute_name} => false) }"
67
+ end
68
+ end
69
+
70
+ def _attribute_name_set_string_validate
71
+ unless @_ae_validate.is_a?(Hash) and !@_ae_validate[:allow_nil].nil?
72
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
73
+ validates :#{@_ae_attribute_name}, presence: true
74
+ RUBY
75
+ end
76
+
77
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
78
+ validates :#{@_ae_attribute_name}, inclusion: {in: #{@_ae_inclusion}}, unless: :"read_attribute(:#{@_ae_attribute_name}).nil?"
79
+ RUBY
80
+ end
81
+
82
+ def _attribute_name_set_boolean_text_method
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
90
+ else
91
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
92
+ def #{_ae_text_method_name}
93
+ return '' if read_attribute(:#{@_ae_attribute_name}).nil?
94
+ read_attribute(:#{@_ae_attribute_name}) ? 'Yes' : 'No'
95
+ end
96
+ RUBY
97
+ end
98
+ end
99
+
100
+ def _attribute_name_set_string_text_method
101
+ 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
108
+ else
109
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
110
+ def #{_ae_text_method_name}
111
+ return '' if read_attribute(:#{@_ae_attribute_name}).nil?
112
+ read_attribute(:#{@_ae_attribute_name}).to_s
113
+ end
114
+ RUBY
115
+ end
116
+ end
117
+
118
+ end
119
+ end
120
+
121
+ end
122
+
@@ -0,0 +1,168 @@
1
+ module AttributeEnums
2
+ module Common
3
+
4
+ def attribute_enums(attribute_name, options={})
5
+ _ae_init_instance_variables
6
+
7
+ @_ae_attribute_name = attribute_name.to_s
8
+
9
+ @_ae_in = options.has_key?(:in) ? Array(options.delete(:in)) : []
10
+ @_ae_boolean = options.has_key?(:boolean) ? options.delete(:boolean) : false
11
+ @_ae_default = options.has_key?(:default) ? options.delete(:default) : nil
12
+ @_ae_ask_methods = options.has_key?(:ask_methods) ? options.delete(:ask_methods) : false
13
+ @_ae_scopeds = options.has_key?(:scopeds) ? options.delete(:scopeds) : false
14
+ @_ae_validate = options.has_key?(:validate) ? options.delete(:validate) : false
15
+ @_ae_i18n = options.has_key?(:i18n) ? options.delete(:i18n) : false
16
+
17
+
18
+ # build _in
19
+ if @_ae_boolean
20
+ @_ae_in = [true, false]
21
+ @_ae_inclusion = @_ae_in
22
+ else
23
+ return if @_ae_in.empty?
24
+ @_ae_in = @_ae_in.map{|x| x.to_s.to_sym}.uniq.flatten.delete_if{|y| y.empty?}
25
+ return if @_ae_in.empty?
26
+ @_ae_inclusion = @_ae_in.map{|x| [x, x.to_s]}.flatten
27
+ end
28
+
29
+ unless @_ae_default.nil?
30
+ raise 'default value not match' unless @_ae_inclusion.include?(@_ae_default)
31
+ end
32
+
33
+ _ae_set_default unless @_ae_default.nil?
34
+ if @_ae_scopeds
35
+ if @_ae_boolean
36
+ _ae_set_boolean_scopeds
37
+ else
38
+ _ae_set_string_scopeds
39
+ end
40
+ end
41
+
42
+
43
+ if @_ae_boolean
44
+ _attribute_name_set_boolean_values_method
45
+ _attribute_name_set_boolean_text_method
46
+ else
47
+ _attribute_name_set_string_values_method
48
+ _attribute_name_set_string_text_method
49
+ end
50
+
51
+
52
+ unless @_ae_boolean
53
+ _ae_set_string_ask_methods if @_ae_ask_methods
54
+ _attribute_name_set_string_validate if @_ae_validate
55
+ end
56
+
57
+ _ae_remove_instance_variables
58
+ end
59
+
60
+
61
+
62
+ private
63
+
64
+ def _ae_instance_variable_names
65
+ %w(attribute_name in boolean default ask_methods scopeds validate i18n inclusion)
66
+ end
67
+
68
+ def _ae_init_instance_variables
69
+ _ae_instance_variable_names.each do |name|
70
+ instance_variable_set "@_ae_#{name}", nil
71
+ end
72
+ end
73
+
74
+ def _ae_remove_instance_variables
75
+ _ae_instance_variable_names.each do |name|
76
+ remove_instance_variable "@_ae_#{name}"
77
+ end
78
+ end
79
+
80
+ def _ae_valid_prefix?(prefix)
81
+ (prefix.is_a?(String) or prefix.is_a?(Symbol)) and !prefix.empty?
82
+ end
83
+
84
+ def _ae_ask_methods_string_attribute_method_name(_in)
85
+ prefix = ''
86
+ if @_ae_ask_methods.is_a?(Hash)
87
+ _prefix = @_ae_ask_methods[:prefix]
88
+ if (_prefix.is_a?(String) or _prefix.is_a?(Symbol)) and !_prefix.empty?
89
+ prefix = _prefix
90
+ end
91
+ end
92
+ ("%s%s?" % [prefix, _in]).to_sym
93
+ end
94
+
95
+ def _ae_scopeds_string_attribute_method_name(_in)
96
+ prefix = ''
97
+ if @_ae_scopeds.is_a?(Hash)
98
+ _prefix = @_ae_scopeds[:prefix]
99
+ if _ae_valid_prefix?(_prefix)
100
+ prefix = _prefix
101
+ end
102
+ end
103
+ ("%s%s" % [prefix, _in]).to_sym
104
+ end
105
+
106
+ def _ae_values_method_name
107
+ ("get_%s_values" % @_ae_attribute_name).to_sym
108
+ end
109
+
110
+ def _ae_text_method_name
111
+ ("%s_text" % @_ae_attribute_name).to_sym
112
+ end
113
+
114
+ def _ae_i18n_t_prefix
115
+ t_prefix = ''
116
+ if @_ae_scopeds.is_a?(Hash)
117
+ _t_prefix = @_ae_scopeds[:t_prefix]
118
+ t_prefix = _t_prefix if _ae_valid_prefix?(_t_prefix)
119
+ end
120
+ t_prefix
121
+ end
122
+
123
+
124
+ def _attribute_name_set_boolean_values_method
125
+ if @_ae_i18n and defined?(::I18n)
126
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
127
+ def self.#{_ae_values_method_name}
128
+ #{@_ae_in}.map do |_in|
129
+ [I18n.translate('enums.%s%s.%s' % ['#{_ae_i18n_t_prefix}', :#{@_ae_attribute_name}, _in]), _in]
130
+ end
131
+ end
132
+ RUBY
133
+ else
134
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
135
+ def self.#{_ae_values_method_name}
136
+ #{@_ae_in}.map do |_in|
137
+ [(_in ? 'Yes' : 'No'), _in]
138
+ end
139
+ end
140
+ RUBY
141
+ end
142
+ end
143
+
144
+ def _attribute_name_set_string_values_method
145
+ if @_ae_i18n and defined?(::I18n)
146
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
147
+ def self.#{_ae_values_method_name}
148
+ #{@_ae_in}.map do |_in|
149
+ [I18n.translate('enums.%s%s.%s' % ['#{_ae_i18n_t_prefix}', :#{@_ae_attribute_name}, _in]), _in.to_s]
150
+ end
151
+ end
152
+ RUBY
153
+ else
154
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
155
+ def self.#{_ae_values_method_name}
156
+ #{@_ae_in}.map do |_in|
157
+ [_in.to_s, _in.to_s]
158
+ end
159
+ end
160
+ RUBY
161
+ end
162
+ end
163
+
164
+
165
+
166
+ end
167
+ end
168
+