Sha256: 2894af16f832252e0d812b924e188425c32230a0e34b90778d2c31e7aac042f2

Contents?: true

Size: 442 Bytes

Versions: 21

Compression:

Stored size: 442 Bytes

Contents

module Superstore
  module Timestamps
    extend ActiveSupport::Concern

    included do
      attribute :created_at, type: :time
      attribute :updated_at, type: :time

      before_create do
        self.created_at ||= Time.current
        self.updated_at ||= Time.current
      end

      before_update if: :changed? do
        self.updated_at = Time.current unless self.changed_attributes.key?("updated_at")
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
superstore-2.4.4 lib/superstore/timestamps.rb
superstore-2.4.3 lib/superstore/timestamps.rb
superstore-2.4.2 lib/superstore/timestamps.rb
superstore-2.4.1 lib/superstore/timestamps.rb
superstore-2.4.0 lib/superstore/timestamps.rb
superstore-2.3.0 lib/superstore/timestamps.rb
superstore-2.2.0 lib/superstore/timestamps.rb
superstore-2.1.3 lib/superstore/timestamps.rb
superstore-2.1.2 lib/superstore/timestamps.rb
superstore-2.1.1 lib/superstore/timestamps.rb
superstore-2.1.0 lib/superstore/timestamps.rb
superstore-2.0.1 lib/superstore/timestamps.rb
superstore-2.0.0 lib/superstore/timestamps.rb
superstore-1.2.0 lib/superstore/timestamps.rb
superstore-1.1.4 lib/superstore/timestamps.rb
superstore-1.1.3 lib/superstore/timestamps.rb
superstore-1.1.2 lib/superstore/timestamps.rb
superstore-1.1.1 lib/superstore/timestamps.rb
superstore-1.1.0 lib/superstore/timestamps.rb
superstore-1.0.12 lib/superstore/timestamps.rb