lib/simple_enum.rb in simple_enum-1.3.1 vs lib/simple_enum.rb in simple_enum-1.3.2
- old
+ new
@@ -19,11 +19,11 @@
# Base module which gets included in <tt>ActiveRecord::Base</tt>. See documentation
# of +SimpleEnum::ClassMethods+ for more details.
module SimpleEnum
# +SimpleEnum+ version string.
- VERSION = "1.3.1".freeze
+ VERSION = "1.3.2".freeze
class << self
# Provides configurability to SimpleEnum, allows to override some defaults which are
# defined for all uses of +as_enum+. Most options from +as_enum+ are available, such as:
@@ -187,13 +187,13 @@
return read_inheritable_attribute(#{enum_attr.inspect}) if args.first.nil?
return read_inheritable_attribute(#{enum_attr.inspect})[args.first] if args.size == 1
args.inject([]) { |ary, sym| ary << read_inheritable_attribute(#{enum_attr.inspect})[sym]; ary }
end
- def self.#{attr_name}_for_select(&block)
+ def self.#{attr_name}_for_select(attr = :key, &block)
self.#{attr_name}.map do |k,v|
- [block_given? ? yield(k,v) : self.human_enum_name(#{attr_name.inspect}, k), k]
- end.sort
+ [block_given? ? yield(k,v) : self.human_enum_name(#{attr_name.inspect}, k), attr == :value ? v : k]
+ end
end
RUBY
# only create if :slim is not defined
if options[:slim] != true