Sha256: 9307ad80f55edcbc3311d8de9cd0b8d44a2abb3b0facb481e1ab3292679a8332

Contents?: true

Size: 899 Bytes

Versions: 15

Compression:

Stored size: 899 Bytes

Contents

require 'deas/view_handler'
require 'deas/url'

module Deas
  class RedirectProxy

    attr_reader :handler_class_name, :handler_class

    def initialize(path = nil, &block)
      @handler_class = Class.new do
        include Deas::ViewHandler

        def self.redirect_path; @redirect_path; end
        def self.redirect_path=(value)
          @redirect_path = value
        end

        def self.name; 'Deas::RedirectHandler'; end

        attr_reader :redirect_path

        def init!
          @redirect_path = self.instance_eval(&self.class.redirect_path)
        end

        def run!
          redirect @redirect_path
        end

      end

      @handler_class.redirect_path = if path.nil?
        block
      elsif path.kind_of?(Deas::Url)
        proc{ path.path_for(params) }
      else
        proc{ path }
      end
      @handler_class_name = @handler_class.name
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
deas-0.26.0 lib/deas/redirect_proxy.rb
deas-0.25.0 lib/deas/redirect_proxy.rb
deas-0.24.1 lib/deas/redirect_proxy.rb
deas-0.24.0 lib/deas/redirect_proxy.rb
deas-0.23.4 lib/deas/redirect_proxy.rb
deas-0.23.3 lib/deas/redirect_proxy.rb
deas-0.23.2 lib/deas/redirect_proxy.rb
deas-0.23.1 lib/deas/redirect_proxy.rb
deas-0.23.0 lib/deas/redirect_proxy.rb
deas-0.22.1 lib/deas/redirect_proxy.rb
deas-0.22.0 lib/deas/redirect_proxy.rb
deas-0.21.0 lib/deas/redirect_proxy.rb
deas-0.20.0 lib/deas/redirect_proxy.rb
deas-0.19.0 lib/deas/redirect_proxy.rb
deas-0.18.0 lib/deas/redirect_proxy.rb