Module: Mongoid::Extensions::Set::ClassMethods

Defined in:
lib/mongoid/extensions/set.rb

Instance Method Summary collapse

Instance Method Details

#demongoize(object) ⇒ Set

Convert the object from its mongo friendly ruby type to this type.

Examples:

Demongoize the object.

Set.demongoize({ "min" => 1, "max" => 5 })

Parameters:

  • object (Hash)

    The object to demongoize.

Returns:

  • (Set)

    The set.

Since:

  • 3.0.0


31
32
33
# File 'lib/mongoid/extensions/set.rb', line 31

def demongoize(object)
  ::Set.new(object)
end

#mongoize(object) ⇒ Hash

Turn the object from the ruby type we deal with to a Mongo friendly type.

Examples:

Mongoize the object.

Set.mongoize(1..3)

Parameters:

  • object (Set)

    The object to mongoize.

Returns:

  • (Hash)

    The object mongoized.

Since:

  • 3.0.0


46
47
48
# File 'lib/mongoid/extensions/set.rb', line 46

def mongoize(object)
  object.to_a
end