Module: MongoidExtended::ObjectId::HashRepresentation

Defined in:
lib/mongoid_extended/object_id.rb

Overview

rewrite methods ‘BSON::ObjectId#as_json` & `BSON::ObjectId#to_json` Return the object id as a JSON hash representation.

Examples:

Get the object id as JSON.

object_id.as_json

Returns:

  • (String)

    The object id as a JSON string.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#as_json(*args) ⇒ Object

Since:

  • 2.0.0



31
32
33
# File 'lib/mongoid_extended/object_id.rb', line 31

def as_json(*args)
  to_s
end

#to_json(*args) ⇒ Object

Since:

  • 2.0.0



27
28
29
# File 'lib/mongoid_extended/object_id.rb', line 27

def to_json(*args)
  to_s
end