Sha256: 180f908771cb81208f7ac07d9eba979440042e66dd9d626a62146374818522c8

Contents?: true

Size: 1.51 KB

Versions: 34

Compression:

Stored size: 1.51 KB

Contents

# encoding: utf-8
module Mongoid
  class Criteria
    module Queryable
      module Extensions

        # This module contains additional time behaviour.
        module Time

          # Evolve the time as a date, UTC midnight.
          #
          # @example Evolve the time to a date query format.
          #   time.__evolve_date__
          #
          # @return [ Time ] The date at midnight UTC.
          #
          # @since 1.0.0
          def __evolve_date__
            ::Time.utc(year, month, day, 0, 0, 0, 0)
          end

          # Evolve the time into a utc time.
          #
          # @example Evolve the time.
          #   time.__evolve_time__
          #
          # @return [ Time ] The time in UTC.
          #
          # @since 1.0.0
          def __evolve_time__
            utc
          end

          module ClassMethods

            # Evolve the object to an date.
            #
            # @example Evolve dates.
            #
            # @example Evolve string dates.
            #
            # @example Evolve date ranges.
            #
            # @param [ Object ] object The object to evolve.
            #
            # @return [ Time ] The evolved date time.
            #
            # @since 1.0.0
            def evolve(object)
              object.__evolve_time__
            end
          end
        end
      end
    end
  end
end

::Time.__send__(:include, Mongoid::Criteria::Queryable::Extensions::Time)
::Time.__send__(:extend, Mongoid::Criteria::Queryable::Extensions::Time::ClassMethods)

Version data entries

34 entries across 32 versions & 2 rubygems

Version Path
mongoid-6.4.8 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.7 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.5 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.8 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.7 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.6 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.5 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.4 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.4 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.3 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.2 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.2 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.1 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.1 lib/mongoid/criteria/queryable/extensions/time.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.0 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.4.0 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.3.0 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-6.2.1 lib/mongoid/criteria/queryable/extensions/time.rb
mongoid-7.0.0.beta lib/mongoid/criteria/queryable/extensions/time.rb