class RackReverseProxy::Rule::Matches
Attributes
has_custom_url[R]
headers[R]
path[R]
rackreq[R]
spec[R]
spec_arity[R]
url[R]
Public Class Methods
new(spec, url, path, accept_headers, has_custom_url, headers, rackreq, *_)
click to toggle source
FIXME: eliminate :url, :accept_headers, :has_custom_url
# File lib/rack_reverse_proxy/rule.rb, line 127 def initialize(spec, url, path, accept_headers, has_custom_url, headers, rackreq, *_) @spec = spec @url = url @path = path @has_custom_url = has_custom_url @rackreq = rackreq @headers = headers if accept_headers @spec_arity = spec.method(spec_match_method_name).arity end
Public Instance Methods
any?()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 138 def any? found.any? end
custom_url()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 142 def custom_url return url unless has_custom_url found.map do |match| match.url(path) end.first end
substitute(url)
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 149 def substitute(url) found.each_with_index.inject(url) do |acc, (match, i)| acc.gsub("$#{i}", match) end end
transform(response, request_uri)
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 155 def transform(response, request_uri) found.inject(response) do |accumulator, match| if match.respond_to?(:transform) match.transform(accumulator, request_uri) else accumulator end end end
Private Instance Methods
_spec_param_count()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 195 def _spec_param_count return 1 if spec_arity == -1 spec_arity end
_spec_params()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 183 def _spec_params [ path, headers, rackreq ][0...spec_param_count] end
find_matches()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 173 def find_matches Array( spec.send(spec_match_method_name, *spec_params) ) end
found()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 169 def found @_found ||= find_matches end
spec_match_method_name()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 200 def spec_match_method_name return :match if spec.respond_to?(:match) :call end
spec_param_count()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 191 def spec_param_count @_spec_param_count ||= _spec_param_count end
spec_params()
click to toggle source
# File lib/rack_reverse_proxy/rule.rb, line 179 def spec_params @_spec_params ||= _spec_params end