Sha256: 1483589b46609f3c3edab64998fd65f1861efbe734a0a95ce00766f895cf2be8

Contents?: true

Size: 1.3 KB

Versions: 59

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8
module Mongoid
  module Extensions
    module Set

      # Turn the object from the ruby type we deal with to a Mongo friendly
      # type.
      #
      # @example Mongoize the object.
      #   set.mongoize
      #
      # @return [ Array ] The object mongoized.
      #
      # @since 3.0.0
      def mongoize
        ::Set.mongoize(self)
      end

      module ClassMethods

        # Convert the object from its mongo friendly ruby type to this type.
        #
        # @example Demongoize the object.
        #   Set.demongoize([1, 2, 3])
        #
        # @param [ Array ] object The object to demongoize.
        #
        # @return [ Set ] The set.
        #
        # @since 3.0.0
        def demongoize(object)
          ::Set.new(object)
        end

        # Turn the object from the ruby type we deal with to a Mongo friendly
        # type.
        #
        # @example Mongoize the object.
        #   Set.mongoize(Set.new([1,2,3]))
        #
        # @param [ Set ] object The object to mongoize.
        #
        # @return [ Array ] The object mongoized.
        #
        # @since 3.0.0
        def mongoize(object)
          object.to_a
        end
      end
    end
  end
end

::Set.__send__(:include, Mongoid::Extensions::Set)
::Set.extend(Mongoid::Extensions::Set::ClassMethods)

Version data entries

59 entries across 55 versions & 3 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/extensions/set.rb
mongoid-7.0.0 lib/mongoid/extensions/set.rb
mongoid-6.4.0 lib/mongoid/extensions/set.rb
mongoid-6.3.0 lib/mongoid/extensions/set.rb
mongoid-6.2.1 lib/mongoid/extensions/set.rb
mongoid-7.0.0.beta lib/mongoid/extensions/set.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/extensions/set.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/lib/mongoid/extensions/set.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/extensions/set.rb
mongoid-6.2.0 lib/mongoid/extensions/set.rb
mongoid-6.1.1 lib/mongoid/extensions/set.rb
mongoid-5.2.1 lib/mongoid/extensions/set.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/lib/mongoid/extensions/set.rb
mongoid-6.1.0 lib/mongoid/extensions/set.rb
mongoid-5.2.0 lib/mongoid/extensions/set.rb
mongoid-5.2.0.rc0 lib/mongoid/extensions/set.rb
mongoid-6.1.0.rc0 lib/mongoid/extensions/set.rb
mongoid-6.0.3 lib/mongoid/extensions/set.rb
mongoid-5.1.6 lib/mongoid/extensions/set.rb
mongoid-6.0.2 lib/mongoid/extensions/set.rb