lib/power_enum/enumerated.rb in power_enum-2.10.1 vs lib/power_enum/enumerated.rb in power_enum-2.11.0

- old
+ new

@@ -23,12 +23,12 @@ # SQL load order clause # [:on_lookup_failure] # Specifies the name of a class method to invoke when the +[]+ method is unable to locate a BookingStatus # record for arg. The default is the built-in :enforce_none which returns nil. There are also built-ins for # :enforce_strict (raise and exception regardless of the type for arg), :enforce_strict_literals (raises an - # exception if the arg is a Fixnum or Symbol), :enforce_strict_ids (raises and exception if the arg is a - # Fixnum) and :enforce_strict_symbols (raises an exception if the arg is a Symbol). The purpose of the + # exception if the arg is a Integer or Symbol), :enforce_strict_ids (raises and exception if the arg is a + # Integer) and :enforce_strict_symbols (raises an exception if the arg is a Symbol). The purpose of the # :on_lookup_failure option is that a) under some circumstances a lookup failure is a Bad Thing and action # should be taken, therefore b) a fallback action should be easily configurable. You can also give it a # lambda that takes in a single argument (The arg that was passed to +[]+). # [:name_column] # Override for the 'name' column. By default, assumed to be 'name'. @@ -216,11 +216,11 @@ case arg when Symbol !!lookup_name(arg.id2name) when String !!lookup_name(arg) - when Fixnum + when Integer !!lookup_id(arg) when self true else false @@ -242,11 +242,11 @@ case arg when Symbol !lookup_name(arg.id2name).nil? when String !lookup_name(arg).nil? - when Fixnum + when Integer !lookup_id(arg).nil? when self possible_match = lookup_id(arg.id) !possible_match.nil? && possible_match == arg else @@ -320,19 +320,19 @@ case arg when Symbol lookup_name(arg.id2name) when String lookup_name(arg) - when Fixnum + when Integer lookup_id(arg) when self arg when nil nil else raise TypeError, "#{self.name}[]: argument should"\ - " be a String, Symbol or Fixnum but got a: #{arg.class.name}" + " be a String, Symbol or Integer but got a: #{arg.class.name}" end end private :lookup_enum_by_type # Deals with a lookup failure for the given argument. @@ -388,17 +388,17 @@ raise_record_not_found(arg) end private :enforce_strict def enforce_strict_literals(arg) # :nodoc: - raise_record_not_found(arg) if (Fixnum === arg) || (Symbol === arg) + raise_record_not_found(arg) if (Integer === arg) || (Symbol === arg) nil end private :enforce_strict_literals def enforce_strict_ids(arg) # :nodoc: - raise_record_not_found(arg) if Fixnum === arg + raise_record_not_found(arg) if Integer === arg nil end private :enforce_strict_ids def enforce_strict_symbols(arg) # :nodoc: @@ -419,11 +419,11 @@ # These are instance methods for objects which are enums. module EnumInstanceMethods # Behavior depends on the type of +arg+. # # * If +arg+ is +nil+, returns +false+. - # * If +arg+ is an instance of +Symbol+, +Fixnum+ or +String+, returns the result of +BookingStatus[:foo] == BookingStatus[arg]+. + # * If +arg+ is an instance of +Symbol+, +Integer+ or +String+, returns the result of +BookingStatus[:foo] == BookingStatus[arg]+. # * If +arg+ is an +Array+, returns +true+ if any member of the array returns +true+ for +===(arg)+, +false+ otherwise. # * In all other cases, delegates to +===(arg)+ of the superclass. # # Examples: # @@ -437,10 +437,10 @@ # also raise an exception for any lookup failure of +BookingStatus[arg]+. def ===(arg) case arg when nil false - when Symbol, String, Fixnum + when Symbol, String, Integer return self == self.class[arg] when Array return self.in?(*arg) else super