Sha256: 76a9e05ec1e21f79698eec32a7c799fbcd1faf6a63ec70a3e00daaf2d3c03e19

Contents?: true

Size: 563 Bytes

Versions: 16

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module ContentTouching
    def self.included(base)
      base.after_update(:touch_contents)
    end

    private

    # If the model has a +contents+ association,
    # it updates all their timestamps.
    #
    # CAUTION: Only use on bottom to top releations,
    # e.g. +Alchemy::Picture+ or +Alchemy::Attachment+
    # not on top to bottom ones like +Alchemy::Element+.
    #
    def touch_contents
      return unless respond_to?(:contents)
      contents.update_all(updated_at: Time.current)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
alchemy_cms-4.6.7 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.6 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.5 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.5.1 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.5 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.4 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.3 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.2 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.1 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.6.0 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.5.0 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.4 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.3 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.2 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.1 app/models/concerns/alchemy/content_touching.rb
alchemy_cms-4.4.0 app/models/concerns/alchemy/content_touching.rb