Class: Faraday::Builder::Handler
Overview
borrowed from ActiveSupport::Dependencies::Reference & ActionDispatch::MiddlewareStack::Middleware
Constant Summary collapse
- @@constants =
Hash.new { |h, k| h[k] = k.respond_to?(:constantize) ? k.constantize : Object.const_get(k) }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #build(app) ⇒ Object
-
#initialize(klass, *args, &block) ⇒ Handler
constructor
A new instance of Handler.
- #inspect ⇒ Object
- #klass ⇒ Object
Constructor Details
#initialize(klass, *args, &block) ⇒ Handler
Returns a new instance of Handler.
27 28 29 30 31 |
# File 'lib/faraday/builder.rb', line 27 def initialize(klass, *args, &block) @name = klass.to_s @@constants[@name] = klass if klass.respond_to?(:name) @args, @block = args, block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/faraday/builder.rb', line 25 def name @name end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/faraday/builder.rb', line 36 def ==(other) if other.is_a? Handler self.name == other.name elsif other.respond_to? :name klass == other else @name == other.to_s end end |
#build(app) ⇒ Object
46 47 48 |
# File 'lib/faraday/builder.rb', line 46 def build(app) klass.new(app, *@args, &@block) end |
#inspect ⇒ Object
34 |
# File 'lib/faraday/builder.rb', line 34 def inspect() @name end |
#klass ⇒ Object
33 |
# File 'lib/faraday/builder.rb', line 33 def klass() @@constants[@name] end |