class Rack::Delegate::Configuration
Attributes
actions[R]
Public Class Methods
from_block(&block)
click to toggle source
# File lib/rack/delegate/configuration.rb, line 4 def self.from_block(&block) config = new config.instance_eval(&block) config.actions end
new()
click to toggle source
# File lib/rack/delegate/configuration.rb, line 12 def initialize @actions = [] @constraints = [] @rewriter = Rewriter.new @changer = Rewriter.new @timeout = NetworkErrorResponse end
Public Instance Methods
change() { |request| ... }
click to toggle source
# File lib/rack/delegate/configuration.rb, line 37 def change @changer = Rewriter.new do |request| yield request request end end
from(pattern, to:, constraints: nil)
click to toggle source
# File lib/rack/delegate/configuration.rb, line 20 def from(pattern, to:, constraints: nil) action = Action.new(pattern, Delegator.new(to, @rewriter, @changer, @timeout)) action = Rack::Timeout.new(action) if timeout? constraints = Array(constraints).concat(@constraints) action = ConstrainedAction.new(action, constraints) unless constraints.empty? @actions << action end
rewrite(&block)
click to toggle source
# File lib/rack/delegate/configuration.rb, line 30 def rewrite(&block) @rewriter = Rewriter.new do |uri| uri.instance_eval(&block) uri end end
timeout(response_object = nil, &block)
click to toggle source
# File lib/rack/delegate/configuration.rb, line 44 def timeout(response_object = nil, &block) @timeout = response_object if response_object @timeout = block if block end
Private Instance Methods
constraints(*args, &block)
click to toggle source
# File lib/rack/delegate/configuration.rb, line 51 def constraints(*args, &block) @constraints << args.flatten << block end
timeout?()
click to toggle source
# File lib/rack/delegate/configuration.rb, line 55 def timeout? require 'rack/timeout' true rescue LoadError false end