rails_reroute 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- def index
5
- reroute "status"
6
- end
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
- new_env = reroute_new_env new_route
6
+ reroute_new_env new_route
7
7
  unlock_request
8
- Rails.application.call(new_env)
9
- @_response = new_env["action_controller.instance"].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
- reroute_default_variables.each { |key| new_env[key] = env[key] }
26
- new_env.merge new_paths
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rails_reroute"
3
- s.version = "0.2"
3
+ s.version = "0.2.1"
4
4
 
5
5
  s.authors = ["Nathaniel Barnes"]
6
6
  s.email = ["Nathaniel.R.Barnes@gmail.com"]
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: '0.2'
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-14 00:00:00.000000000 Z
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