Sha256: 57ebc9e2018ee91462fd26b3e792089f5005cfd32610ecad8685594e0b0c454a

Contents?: true

Size: 531 Bytes

Versions: 48

Compression:

Stored size: 531 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_save(:touch_elements)
    end

    private

    def touch_elements
      return unless respond_to?(:elements)

      elements.map(&:touch)
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
alchemy_cms-5.3.8 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.7 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.6 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.5 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.4 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.3 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.2 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.3.0 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.7 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.6 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.10 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.10 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.5 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.9 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.9 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.4 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.8 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.8 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.7 app/models/concerns/alchemy/touch_elements.rb