Class: RailsAdmin::Adapters::Mongoid::Bson

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_admin/adapters/mongoid/bson.rb

Constant Summary collapse

OBJECT_ID =
begin
  if defined?(Moped::BSON)
    Moped::BSON::ObjectId
  elsif defined?(BSON::ObjectId)
    BSON::ObjectId
  end
end

Class Method Summary collapse

Class Method Details

.parse_object_id(value) ⇒ Object


16
17
18
19
20
21
22
23
24
# File 'lib/rails_admin/adapters/mongoid/bson.rb', line 16

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