Module: EnumExtensions::EnumWithStringValues
- Defined in:
- lib/enum_extensions/enum_with_string_values.rb
Instance Method Summary collapse
Instance Method Details
#enum_s(definitions) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/enum_extensions/enum_with_string_values.rb', line 5 def enum_s definitions definitions.each do |name, values| fail ArgumentError unless values.is_a? Array values_s = ActiveSupport::OrderedHash.new values.each do |value| values_s[value.to_sym] = value.to_s end enum name => values_s end end |
#simple_enum_s(definitions) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/enum_extensions/enum_with_string_values.rb', line 18 def simple_enum_s definitions definitions.each do |name, values| fail ArgumentError unless values.is_a? Array values_s = ActiveSupport::OrderedHash.new values.each do |value| values_s[value.to_sym] = value.to_s end simple_enum name => values_s end end |