Sha256: e380ade7025b53c4b6f85614c63f6b518c1a90dd118d0c747e77a613911293af

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module Tuning
  module Extensions
    module ActionController
      module Base
        extend ActiveSupport::Concern

        included do
          define_callbacks :render
        end

        def render(*args)
          run_callbacks(:render) do
            super
          end
        end

        module ClassMethods

          %i(before after around).each do |callback|
            define_method "#{callback}_render" do |*names, &block|
              _insert_callbacks(args, block) do |name, options|
                set_callback :render, callback, name, options
              end
            end

            define_method "prepend_#{callback}_render" do |*names, &block|
              _insert_callbacks(args, block) do |name, options|
                set_callback :render, callback, name, options.merge(prepend: true)
              end
            end

            define_method "skip_#{callback}_render" do |*names|
              _insert_callbacks(args) do |name, options|
                skip_callback :render, callback, name, options
              end
            end

            alias_method :"append_#{callback}_render", :"#{callback}_render"
          end

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tuning-4.0.0.0 lib/tuning/extensions/action_controller/base.rb
tuning-1.0.0 lib/tuning/extensions/action_controller/base.rb