lib/temping.rb in temping-3.5.0 vs lib/temping.rb in temping-3.6.0
- old
+ new
@@ -42,15 +42,23 @@
end
private
def build
- Class.new(ActiveRecord::Base).tap do |klass|
+ Class.new(model_parent_class).tap do |klass|
Object.const_set(@model_name, klass)
klass.primary_key = :id
create_table(@options)
add_methods
+ end
+ end
+
+ def model_parent_class
+ if ActiveRecord::VERSION::MAJOR > 4 && defined?(ApplicationRecord)
+ ApplicationRecord
+ else
+ ActiveRecord::Base
end
end
DEFAULT_OPTIONS = { :temporary => true }
def create_table(options = {})