Sha256: dfb245cd4aed8212f4eb4102304541fc6d0c97dfcecc6ba9c2879c2a12f43666
Contents?: true
Size: 968 Bytes
Versions: 4
Compression:
Stored size: 968 Bytes
Contents
module CucumberFactory module Switcher extend self def find_last(klass) # Don't use class.last, in sqlite that is not always the last inserted element # If created_at is available prefer it over id as column for ordering so that we can handle UUIDs order_column = klass.column_names.include?('created_at') ? 'created_at, id' : 'id' if active_record_version < 4 klass.find(:last, :order => order_column) else klass.order(order_column).last end end def assign_attributes(model, attributes) if active_record_version < 3 model.send(:attributes=, attributes, false) # ignore attr_accessible elsif active_record_version < 4 model.send(:assign_attributes, attributes, :without_protection => true) else model.send(:assign_attributes, attributes) end end private def active_record_version ActiveRecord::VERSION::MAJOR end end end
Version data entries
4 entries across 4 versions & 1 rubygems