Sha256: 43474ca1273ba76bc274225e18350e199e481914775af10a875865352335473c

Contents?: true

Size: 640 Bytes

Versions: 21

Compression:

Stored size: 640 Bytes

Contents

require 'mongoid'

module RailsAdmin
  module Adapters
    module Mongoid
      class Bson
        OBJECT_ID = begin
          if defined?(Moped::BSON)
            Moped::BSON::ObjectId
          elsif defined?(BSON::ObjectId)
            BSON::ObjectId
          end
        end

        class << self
          def parse_object_id(value)
            OBJECT_ID.from_string(value)
          rescue => e
            raise e if %w(
              Moped::Errors::InvalidObjectId
              BSON::ObjectId::Invalid
              BSON::InvalidObjectId
            ).exclude?(e.class.to_s)
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rails_admin-2.3.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.3.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.2.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.2.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.1.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.1.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.0.2 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.4.3 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.0.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.0.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.0.0.rc lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-2.0.0.beta lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.4.2 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.4.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.4.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.3.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.2.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.1.1 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.1.0 lib/rails_admin/adapters/mongoid/bson.rb
rails_admin-1.0.0 lib/rails_admin/adapters/mongoid/bson.rb