Sha256: 65b6fb535891856704d8dc013ef4271508081cf8d772fb2e5c5fad88b17303fd

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8
module Mongoid
  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
        Threaded.timeless = true
        self
      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

        # 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
          Threaded.timeless = true
          self
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
mongoid-3.1.3 lib/mongoid/timestamps/timeless.rb
mongoid-3.1.2 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.23 lib/mongoid/timestamps/timeless.rb
mongoid-3.1.1 lib/mongoid/timestamps/timeless.rb
mongoid-3.1.0 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.22 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.21 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.20 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.19 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.18 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.17 lib/mongoid/timestamps/timeless.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/timestamps/timeless.rb
mongoid-3.0.16 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.15 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.14 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.13 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.12 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.11 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.10 lib/mongoid/timestamps/timeless.rb
mongoid-3.0.9 lib/mongoid/timestamps/timeless.rb