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.1.7 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.3 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.6 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.6 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.2 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.5 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.5 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.4 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.4 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.3 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.0 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.0.rc1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.2.0.b1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.2 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.1 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.3 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.0 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.0.2 app/models/concerns/alchemy/touch_elements.rb
alchemy_cms-5.1.0.rc1 app/models/concerns/alchemy/touch_elements.rb