Sha256: b12eae286273fe18be25ff01159d093a2f351d3d178c3132bf57b3e9e415d29c
Contents?: true
Size: 1.22 KB
Versions: 8
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true 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. 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. 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. 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
8 entries across 8 versions & 1 rubygems