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([1, 2, 3])

Parameters:

  • object (Array)

    The object to demongoize.

Returns:

  • (Set)

    The set.



28
29
30
# File 'lib/mongoid/extensions/set.rb', line 28

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

#mongoize(object) ⇒ Array

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

Examples:

Mongoize the object.

Set.mongoize(Set.new([1,2,3]))

Parameters:

  • object (Set)

    The object to mongoize.

Returns:

  • (Array)

    The object mongoized.



41
42
43
# File 'lib/mongoid/extensions/set.rb', line 41

def mongoize(object)
  object.to_a
end