Class: Rack::Rewrite::Action::Redirect

Inherits:
Rack::Rewrite::Action show all
Defined in:
lib/rack_rewrite/actions.rb

Instance Method Summary collapse

Methods inherited from Rack::Rewrite::Action

#method_missing, #query_string=, #respond_to?, #scheme=, #setup

Constructor Details

#initialize(caller, action, status) ⇒ Redirect

Returns a new instance of Redirect.



88
89
90
91
92
# File 'lib/rack_rewrite/actions.rb', line 88

def initialize(caller, action, status)
  @caller = caller
  @action = action
  @status = status
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rack::Rewrite::Action

Instance Method Details

#call(env) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/rack_rewrite/actions.rb', line 94

def call(env)
  setup(env)
  @caller.redirect = [ @status, {'Location'=> case @action
  when Proc
    instance_eval(&@action)
  else
    @action
  end}, []]
  throw :pass
end