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

@@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

- (Handler) initialize(klass, *args, &block)

Returns a new instance of Handler



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

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

- (Object) name (readonly)

Returns the value of attribute name



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

def name
  @name
end

Instance Method Details

- (Object) ==(other)



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

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

- (Object) build(app)



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

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

- (Object) inspect



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

def inspect() @name end

- (Object) klass



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

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