Sha256: f408c0a1e3b6d8665452552a65950d83e19de765f6a57d3ab4220964ed693c4f

Contents?: true

Size: 530 Bytes

Versions: 87

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  # If the model has a +elements+ association,
  # it updates all their timestamps after save.
  #
  # Should only be used on bottom to top relations,
  # e.g. +Alchemy::Picture+ or +Alchemy::Attachment+
  # not on top to bottom ones like +Alchemy::Page+.
  #
  module TouchElements
    def self.included(base)
      base.after_update(:touch_elements)
    end

    private

    def touch_elements
      return unless respond_to?(:elements)

      elements.touch_all
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
alchemy_cms-6.0.0.pre.rc1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.pre.b6 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.pre.b5 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.pre.b4 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.b3 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.b2 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-6.0.0.b1 app/models/concerns/alchemy/touch_elements.rb