Sha256: 9a49f17e28949538dcc01724345b76d49590fe928346dd37ec36c1356ddafef1

Contents?: true

Size: 1.23 KB

Versions: 171

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Timestamps

    # This module adds behaviour for turning off timestamping in single or
    # multiple calls.
    module Timeless
      extend ActiveSupport::Concern

      # Begin an execution that should skip timestamping.
      #
      # @example Save a document but don't timestamp.
      #   person.timeless.save
      #
      # @return [ Document ] The document this was called on.
      #
      # @since 2.3.0
      def timeless
        tap { Threaded.timeless = true }
      end

      # Are we currently timestamping?
      #
      # @example Should timestamps be applied?
      #   person.timestamping?
      #
      # @return [ true, false ] If the current thread is timestamping.
      #
      # @since 2.3.0
      def timestamping?
        Threaded.timestamping?
      end

      module ClassMethods #:nodoc

        # Begin an execution that should skip timestamping.
        #
        # @example Create a document but don't timestamp.
        #   Person.timeless.create(:title => "Sir")
        #
        # @return [ Class ] The class this was called on.
        #
        # @since 2.3.0
        def timeless
          tap { Threaded.timeless = true }
        end
      end
    end
  end
end

Version data entries

171 entries across 79 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
mongoid-2.8.1 lib/mongoid/timestamps/timeless.rb
mongoid-2.8.0 lib/mongoid/timestamps/timeless.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/timestamps/timeless.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/timestamps/timeless.rb