Sha256: 1ca7fd2c256d36b4ebd091263531506609cf203d2b453d5ab80829bd655588d0

Contents?: true

Size: 804 Bytes

Versions: 4

Compression:

Stored size: 804 Bytes

Contents

require 'action_controller/metal/responder'

module Zertico
  class Responder < ActionController::Responder
    autoload :ForceRedirect, 'zertico/responder/force_redirect'
    autoload :Pjax, 'zertico/responder/pjax'

    class << self
      include Rails.application.routes.url_helpers

      def default_url_options; {} end

      %w(index new edit create update show destroy).each do |method_name|
        define_method("#{method_name}_options=") do |options|
          instance_variable_set("@#{method_name}_options", options)
        end

        define_method("#{method_name}_options") do |controller|
          return {} unless instance_variable_defined?("@#{method_name}_options")
          instance_variable_get("@#{method_name}_options").call(controller)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zertico-2.0.0.beta.1 lib/zertico/responder.rb
zertico-2.0.0.alpha.3 lib/zertico/responder.rb
zertico-2.0.0.alpha.2 lib/zertico/responder.rb
zertico-2.0.0.alpha.1 lib/zertico/responder.rb