rails_reroute 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README → README.md} +9 -6
- data/lib/rails_reroute.rb +5 -6
- data/rails_reroute.gemspec +1 -1
- metadata +3 -3
data/{README → README.md}
RENAMED
@@ -1,11 +1,14 @@
|
|
1
|
+
Rails Reroute
|
2
|
+
================================
|
3
|
+
|
1
4
|
Rails reroute allows you to full reroute your request from within a controller without having to duplicate code across controllers. Just plug it in and it works.
|
2
5
|
|
3
|
-
class AirTrafficController < ApplicationController
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
6
|
+
class AirTrafficController < ApplicationController
|
7
|
+
def index
|
8
|
+
reroute "status"
|
9
|
+
end
|
10
|
+
end
|
8
11
|
|
9
12
|
You can add it to your project by adding this to your Gemfile
|
10
13
|
|
11
|
-
gem 'rails_reroute', :require => 'rails_reroute'
|
14
|
+
gem 'rails_reroute', :require => 'rails_reroute'
|
data/lib/rails_reroute.rb
CHANGED
@@ -3,10 +3,10 @@ module RailsReroute
|
|
3
3
|
initializer "rails_reroute.initializer" do
|
4
4
|
ActionController::Base.class_eval do
|
5
5
|
def reroute new_route
|
6
|
-
|
6
|
+
reroute_new_env new_route
|
7
7
|
unlock_request
|
8
|
-
Rails.application.call(
|
9
|
-
@_response =
|
8
|
+
Rails.application.call(env)
|
9
|
+
@_response = env["action_controller.instance"].response
|
10
10
|
@_response_body = @_response.body
|
11
11
|
end
|
12
12
|
|
@@ -20,10 +20,9 @@ module RailsReroute
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def reroute_new_env new_route
|
23
|
-
new_env = env.clone
|
24
23
|
new_paths = {"PATH_INFO" => "#{new_route}", "REQUEST_URI"=>"#{env["rack.url_scheme"]}://#{env["HTTP_HOST"]}#{new_route}", "REQUEST_PATH"=>"#{new_route}"}
|
25
|
-
|
26
|
-
|
24
|
+
env.keys.each { |key| env.delete(key) if !reroute_default_variables.include?(key) and !key.include?("rack") }
|
25
|
+
env.merge! new_paths
|
27
26
|
end
|
28
27
|
|
29
28
|
def unlock_request
|
data/rails_reroute.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_reroute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Reroute rails requests fully
|
15
15
|
email:
|
@@ -21,7 +21,7 @@ files:
|
|
21
21
|
- .gitignore
|
22
22
|
- Gemfile
|
23
23
|
- LICENSE
|
24
|
-
- README
|
24
|
+
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- lib/rails_reroute.rb
|
27
27
|
- rails_reroute.gemspec
|