Skip to content
Browse files

remove Faraday.register_middleware

  • Loading branch information...
1 parent 91dfa11 commit 14b458a9c971897f44d5ee3ba5354de52c998e72 @technoweenie committed Oct 20, 2012
Showing with 2 additions and 35 deletions.
  1. +0 −23 lib/faraday.rb
  2. +2 −12 test/middleware_stack_test.rb
View
23 lib/faraday.rb
@@ -215,29 +215,6 @@ def all_loaded_constants
end
end
- # Public: Register middleware classes under a short name.
- #
- # type - A Symbol specifying the kind of middleware (default: :middleware)
- # mapping - A Hash mapping Symbol keys to classes. Classes can be expressed
- # as fully qualified constant, or a Proc that will be lazily called
- # to return the former.
- #
- # Examples
- #
- # Faraday.register_middleware :aloha => MyModule::Aloha
- # Faraday.register_middleware :response, :boom => MyModule::Boom
- #
- # # shortcuts are now available in Builder:
- # builder.use :aloha
- # builder.response :boom
- #
- # Returns nothing.
- def self.register_middleware(type, mapping = nil)
- type, mapping = :middleware, type if mapping.nil?
- component = self.const_get(type.to_s.capitalize)
- component.register_middleware(mapping)
- end
-
require_libs "utils", "connection", "builder", "parameters", "middleware",
"adapter", "request", "response", "upload_io", "error"
end
View
14 test/middleware_stack_test.rb
@@ -104,7 +104,7 @@ def test_unregistered_symbol
end
def test_registered_symbol
- Faraday.register_middleware :apple => Apple
+ Faraday::Middleware.register_middleware :apple => Apple
begin
build_stack :apple
assert_handlers %w[Apple]
@@ -114,7 +114,7 @@ def test_registered_symbol
end
def test_registered_symbol_with_proc
- Faraday.register_middleware :apple => lambda { Apple }
+ Faraday::Middleware.register_middleware :apple => lambda { Apple }
begin
build_stack :apple
assert_handlers %w[Apple]
@@ -123,16 +123,6 @@ def test_registered_symbol_with_proc
end
end
- def test_registered_symbol_with_type
- Faraday.register_middleware :request, :orange => Orange
- begin
- build_stack {|b| b.request :orange }
- assert_handlers %w[Orange]
- ensure
- unregister_middleware Faraday::Request, :orange
- end
- end
-
def test_missing_dependencies
build_stack Broken
err = assert_raises RuntimeError do

0 comments on commit 14b458a

Please sign in to comment.
Something went wrong with that request. Please try again.