Sha256: 2190e1fbe6310f0724a89402ea88dcad0eb44b04d8c1f4a5697cdf372aa4da22

Contents?: true

Size: 977 Bytes

Versions: 139

Compression:

Stored size: 977 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module OnPageLayout
    # Runs OnPageLayout callbacks
    #
    # Included in +Alchemy::PagesController+ and +Alchemy::Admin::PagesController+
    #
    # @see OnPageLayout in order to learn how to define +on_page_layout+ callbacks.
    #
    module CallbacksRunner
      private

      def run_on_page_layout_callbacks?
        OnPageLayout.callbacks.present?
      end

      def run_on_page_layout_callbacks
        OnPageLayout.callbacks.each do |page_layout, callbacks|
          next unless call_page_layout_callback_for?(page_layout)

          callbacks.each do |callback|
            if callback.respond_to?(:call)
              instance_eval(&callback)
            else
              send(callback)
            end
          end
        end
      end

      def call_page_layout_callback_for?(page_layout)
        page_layout.to_sym == :all || @page.page_layout.to_sym == page_layout.to_sym
      end
    end
  end
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
alchemy_cms-7.3.5 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.8 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.1.13 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.0.16 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.3.4 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.3.3 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.3.2 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.7 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.3.1 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.3.0 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.6 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.5 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.1.12 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.0.15 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-6.1.10 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.4 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.1.11 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.3 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.1.10 lib/alchemy/on_page_layout/callbacks_runner.rb
alchemy_cms-7.2.2 lib/alchemy/on_page_layout/callbacks_runner.rb