Sha256: e148538addd149d583c835fe0c394484a98d7f8e97ad6ff3e2e61c62be56e6b1

Contents?: true

Size: 732 Bytes

Versions: 5

Compression:

Stored size: 732 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 Rails::VERSION::MAJOR < 4
        klass.find(:last, :order => "id")
      else
        klass.order(:id).last
      end
    end

    def assign_attributes(model, attributes)
      if Rails::VERSION::MAJOR < 3 || (Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR < 2)
        model.send(:attributes=, attributes, false) # ignore attr_accessible
      elsif Rails::VERSION::MAJOR < 4
        model.send(:assign_attributes, attributes, :without_protection => true)
      else
        model.send(:assign_attributes, attributes)
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cucumber_factory-1.11.2 lib/cucumber_factory/switcher.rb
cucumber_factory-1.11.1 lib/cucumber_factory/switcher.rb
cucumber_factory-1.11.0 lib/cucumber_factory/switcher.rb
cucumber_factory-1.10.0 lib/cucumber_factory/switcher.rb
cucumber_factory-1.9.2 lib/cucumber_factory/switcher.rb