Sha256: 66184750036c89ba3a6df2b3ff33ea51a39348a0977b78bf33ee03291730e7d3

Contents?: true

Size: 788 Bytes

Versions: 29

Compression:

Stored size: 788 Bytes

Contents

# frozen_string_literal: true

module PagesCore
  module Templates
    module ControllerActions
      extend ActiveSupport::Concern

      module ClassMethods
        def template_actions
          @template_actions ||= Hash.new { |hash, key| hash[key] = [] }
        end

        def template(*names, &block)
          Array(names).each do |name|
            name = name.to_s unless name == :all
            template_actions[name] << block
          end
        end

        def template_actions_for(name)
          template_actions[:all] + template_actions[name.to_s]
        end
      end

      def run_template_actions_for(template, *args)
        self.class.template_actions_for(template).each do |proc|
          instance_exec(*args, &proc)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pages_core-3.15.5 lib/pages_core/templates/controller_actions.rb
pages_core-3.15.4 lib/pages_core/templates/controller_actions.rb
pages_core-3.15.3 lib/pages_core/templates/controller_actions.rb
pages_core-3.15.2 lib/pages_core/templates/controller_actions.rb
pages_core-3.15.1 lib/pages_core/templates/controller_actions.rb
pages_core-3.14.0 lib/pages_core/templates/controller_actions.rb
pages_core-3.13.0 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.7 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.6 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.5 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.4 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.3 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.2 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.1 lib/pages_core/templates/controller_actions.rb
pages_core-3.12.0 lib/pages_core/templates/controller_actions.rb
pages_core-3.11.3 lib/pages_core/templates/controller_actions.rb
pages_core-3.11.2 lib/pages_core/templates/controller_actions.rb
pages_core-3.11.1 lib/pages_core/templates/controller_actions.rb
pages_core-3.11.0 lib/pages_core/templates/controller_actions.rb
pages_core-3.10.2 lib/pages_core/templates/controller_actions.rb