Sha256: b1c22e8a7388ee5613524f8d9cae5f9e83aadf89a63ac4662e2bcff27aabbad1

Contents?: true

Size: 818 Bytes

Versions: 16

Compression:

Stored size: 818 Bytes

Contents

require_relative '../../app/models/qbrick/placeholder_brick'

module Qbrick
  module TouchPlaceholders
    def self.included(base)
      base.extend(ClassMethods)

      base.class_eval do
        after_save :touch_placeholders
      end
    end

    def touch_placeholders
      return unless self.class.placeholder_templates.present?
      self.class.placeholder_templates.each do |template_name|
        related_templates = Qbrick::PlaceholderBrick.where(template_name: template_name)
        related_templates.each(&:touch) if related_templates
      end
    end

    module ClassMethods
      def placeholder_templates(*attributes)
        if attributes.empty?
          @shoestrap_placeholder_templates
        else
          @shoestrap_placeholder_templates = attributes
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
qbrick-2.7.1 lib/qbrick/touch_placeholders.rb
qbrick-2.7 lib/qbrick/touch_placeholders.rb
qbrick-2.6.10 lib/qbrick/touch_placeholders.rb
qbrick-2.6.9 lib/qbrick/touch_placeholders.rb
qbrick-2.6.8 lib/qbrick/touch_placeholders.rb
qbrick-2.6.7 lib/qbrick/touch_placeholders.rb
qbrick-2.6.6 lib/qbrick/touch_placeholders.rb
qbrick-2.6.5 lib/qbrick/touch_placeholders.rb
qbrick-2.6.4 lib/qbrick/touch_placeholders.rb
qbrick-2.6.3 lib/qbrick/touch_placeholders.rb
qbrick-2.6.2 lib/qbrick/touch_placeholders.rb
qbrick-2.6.1 lib/qbrick/touch_placeholders.rb
qbrick-2.6.0 lib/qbrick/touch_placeholders.rb
qbrick-2.5.2 lib/qbrick/touch_placeholders.rb
qbrick-2.5.1 lib/qbrick/touch_placeholders.rb
qbrick-2.5.0 lib/qbrick/touch_placeholders.rb