Sha256: c5602a24c74c2c2ef3209db91eaa96ab8d42c76c55b4cc458d4394c2ca85aa02
Contents?: true
Size: 1.19 KB
Versions: 29
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true # A class which sends values to the database as Strings but returns them to the user as Symbols. module Mongoid class StringifiedSymbol class << self # Convert the object from its mongo friendly ruby type to this type. # # @example Demongoize the object. # Mongoid::StringifiedSymbol.demongoize(object) # # @param [ Object ] object The object to demongoize. # # @return [ Symbol ] The object. # # @api private def demongoize(object) if object.nil? object else object.to_s.to_sym end end # Turn the object from the ruby type we deal with to a Mongo friendly # type. # # @example Mongoize the object. # Mongoid::StringifiedSymbol.mongoize("123.11") # # @param [ Object ] object The object to mongoize. # # @return [ Symbol ] The object mongoized. # # @api private def mongoize(object) if object.nil? object else object.to_s end end # @api private def evolve(object) mongoize(object) end end end end
Version data entries
29 entries across 29 versions & 1 rubygems