Class: Faraday::Builder::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/faraday/builder.rb

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

Instance Method Summary collapse

Constructor Details

#initialize(klass, *args, &block) ⇒ Handler

Returns a new instance of Handler.



24
25
26
27
28
# File 'lib/faraday/builder.rb', line 24

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

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/faraday/builder.rb', line 22

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/faraday/builder.rb', line 33

def ==(other)
  if other.respond_to? :name
    klass == other
  else
    @name == other.to_s
  end
end

#build(app) ⇒ Object



41
42
43
# File 'lib/faraday/builder.rb', line 41

def build(app)
  klass.new(app, *@args, &@block)
end

#inspectObject



31
# File 'lib/faraday/builder.rb', line 31

def inspect() @name end

#klassObject



30
# File 'lib/faraday/builder.rb', line 30

def klass() @@constants[@name] end