Class: Faraday::RackBuilder::Handler
- Inherits:
-
Object
- Object
- Faraday::RackBuilder::Handler
- Defined in:
- lib/faraday/rack_builder.rb
Overview
borrowed from ActiveSupport::Dependencies::Reference & ActionDispatch::MiddlewareStack::Middleware
Constant Summary collapse
- REGISTRY =
Faraday::AdapterRegistry.new
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #build(app = nil) ⇒ Object
-
#initialize(klass, *args, **kwargs, &block) ⇒ Handler
constructor
A new instance of Handler.
- #inspect ⇒ Object
- #klass ⇒ Object
Constructor Details
#initialize(klass, *args, **kwargs, &block) ⇒ Handler
Returns a new instance of Handler.
35 36 37 38 39 40 41 |
# File 'lib/faraday/rack_builder.rb', line 35 def initialize(klass, *args, **kwargs, &block) @name = klass.to_s REGISTRY.set(klass) if klass.respond_to?(:name) @args = args @kwargs = kwargs @block = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/faraday/rack_builder.rb', line 33 def name @name end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/faraday/rack_builder.rb', line 51 def ==(other) if other.is_a? Handler name == other.name elsif other.respond_to? :name klass == other else @name == other.to_s end end |
#build(app = nil) ⇒ Object
61 62 63 |
# File 'lib/faraday/rack_builder.rb', line 61 def build(app = nil) klass.new(app, *@args, **@kwargs, &@block) end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/faraday/rack_builder.rb', line 47 def inspect @name end |
#klass ⇒ Object
43 44 45 |
# File 'lib/faraday/rack_builder.rb', line 43 def klass REGISTRY.get(@name) end |