Class: RackReverseProxy::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/rack_reverse_proxy/rule.rb

Overview

Rule understands which urls need to be proxied

Defined Under Namespace

Classes: Candidate, Matches

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, url = nil, options = {}) ⇒ Rule

Returns a new instance of Rule.



7
8
9
10
11
12
# File 'lib/rack_reverse_proxy/rule.rb', line 7

def initialize(spec, url = nil, options = {})
  @has_custom_url = url.nil?
  @url = url
  @options = options
  @spec = build_matcher(spec)
end

Instance Attribute Details

#optionsObject (readonly)

FIXME: It needs to be hidden



5
6
7
# File 'lib/rack_reverse_proxy/rule.rb', line 5

def options
  @options
end

Instance Method Details

#get_uri(path, env, *args) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rack_reverse_proxy/rule.rb', line 18

def get_uri(path, env, *args)
  Candidate.new(
    self,
    has_custom_url,
    path,
    env,
    matches(path, *args)
  ).build_uri
end

#proxy?(path, *args) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rack_reverse_proxy/rule.rb', line 14

def proxy?(path, *args)
  matches(path, *args).any?
end

#to_sObject



28
29
30
# File 'lib/rack_reverse_proxy/rule.rb', line 28

def to_s
  %("#{spec}" => "#{url}")
end