Sha256: ec35014a08570322f8c7d8f7d993d967a582e0029859f18954563e04df4663c9

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

module Mongoid
  module VersionSetup
    def self.configure config
      version = Mongoid::VERSION
      case
      when version < '2'
        raise ArgumentError, "Mongoid versions < 2 not supported"
      when version < '3'
        version_2 config
      when version > '3'
        version_3 config
      end
    end

    def self.version_3 config      
      require 'moped'
      config.connect_to('mongoid_geo_test')      
    end

    def self.version_2 config
      require 'bson'
      
      opts = YAML.load(File.read(File.dirname(__FILE__) + '/support/mongoid.yml'))["test"]
      opts.delete("slaves") # no slaves support for version < 3
      name = opts.delete("database")
      host = opts.delete("host")
      port = opts.delete("port")
      config.master = begin
         Mongo::Connection.new(host, port, opts).db(name)
      rescue Mongo::ConnectionFailure
        Mongo::Connection.new(host, '27017', opts).db(name)
      end
      config.logger = nil
      config.allow_dynamic_fields = true
    end      
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
timespan-0.6.0 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.9 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.7 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.6.1 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.6 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.5 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.4 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.3 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.2 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.1 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.5.0 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.9 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.6 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.5 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.4 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.3 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.2 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.1 spec/timespan/mongoid/mongoid_setup.rb
timespan-0.4.0 spec/timespan/mongoid/mongoid_setup.rb