Class: Deas::RedirectProxy

Inherits:
HandlerProxy show all
Defined in:
lib/deas/redirect_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HandlerProxy

#run

Constructor Details

#initialize(router, path = nil, &block) ⇒ RedirectProxy

Returns a new instance of RedirectProxy.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/deas/redirect_proxy.rb', line 11

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

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

    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.class.router.prepend_base_url(
        self.instance_eval(&self.class.redirect_path)
      )
    end

    def run!
      redirect @redirect_path
    end

  end

  @handler_class.router = router
  @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

Instance Attribute Details

#handler_classObject (readonly)

Returns the value of attribute handler_class.



9
10
11
# File 'lib/deas/redirect_proxy.rb', line 9

def handler_class
  @handler_class
end

#handler_class_nameObject (readonly)

Returns the value of attribute handler_class_name.



9
10
11
# File 'lib/deas/redirect_proxy.rb', line 9

def handler_class_name
  @handler_class_name
end

Instance Method Details

#validate!Object



52
# File 'lib/deas/redirect_proxy.rb', line 52

def validate!; end