lib/simple_enum.rb in simple_enum-1.6.1 vs lib/simple_enum.rb in simple_enum-1.6.2

- old
+ new

@@ -152,12 +152,14 @@ # * <tt>:whiny</tt> - Boolean value which if set to <tt>true</tt> will throw an <tt>ArgumentError</tt> # if an invalid value is passed to the setter (e.g. a value for which no enumeration exists). if set to # <tt>false</tt> no exception is thrown and the internal value is set to <tt>nil</tt> (default is <tt>true</tt>) # * <tt>:dirty</tt> - Boolean value which if set to <tt>true</tt> generates <tt>..._was</tt> and <tt>..._changed?</tt> # methods for the enum, which delegate to the internal column (default is <tt>false</tt>) + # * <tt>:field</tt> - Also allowed as valid key, for Mongoid integration + default options, see simple_enum#27. + # def as_enum(enum_cd, values, options = {}) options = SimpleEnum.default_options.merge({ :column => "#{enum_cd}_cd" }).merge(options) - options.assert_valid_keys(:column, :whiny, :prefix, :slim, :upcase, :dirty) + options.assert_valid_keys(:column, :whiny, :prefix, :slim, :upcase, :dirty, :field) metaclass = (class << self; self; end) # convert array to hash... values = SimpleEnum::EnumHash.new(values)