lib/enumerations/reflection.rb in enumerations-1.3.2 vs lib/enumerations/reflection.rb in enumerations-2.0.0

- old
+ new

@@ -1,18 +1,22 @@ -module Enumeration +module Enumerations class Reflection attr_reader :name - def initialize(name, options) + def initialize(name, options = {}) @name = name @options = options end def class_name - @options[:class_name] + @class_name ||= (@options[:class_name] || name).to_s.camelize end def foreign_key - @options[:foreign_key] + @foreign_key ||= (@options[:foreign_key] || "#{name}_id").to_sym + end + + def enumerator_class + @enumerator_class ||= class_name.constantize end end end