Class: Strawman::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/strawman/proxy.rb

Overview

The general proxy class, which contains functions not specific to any type of proxy.

Direct Known Subclasses

GlypeProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Proxy

Returns a new instance of Proxy.



10
11
12
13
# File 'lib/strawman/proxy.rb', line 10

def initialize(url)
  @root_url = url
  @valid = false
end

Instance Attribute Details

#root_urlObject (readonly)

Returns the value of attribute root_url.



7
8
9
# File 'lib/strawman/proxy.rb', line 7

def root_url
  @root_url
end

#valid=(value) ⇒ Object (writeonly)

Sets the attribute valid

Parameters:

  • value

    the value to set the attribute valid to.



8
9
10
# File 'lib/strawman/proxy.rb', line 8

def valid=(value)
  @valid = value
end

Instance Method Details

#==(other) ⇒ Object



38
39
40
# File 'lib/strawman/proxy.rb', line 38

def ==(other)
  self.class == other.class && self.root_url == other.root_url
end

#proxy_url(url) ⇒ Object

Returns the url to fetch the given url through this proxy.



25
26
27
28
# File 'lib/strawman/proxy.rb', line 25

def proxy_url(url)
  uri = URI.join @root_url, proxy_path(url)
  "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}?#{uri.query}"
end

#refererObject

Returns the the referer to use when making the proxied request.



18
19
20
# File 'lib/strawman/proxy.rb', line 18

def referer
  @root_url
end

#valid?Boolean

Used to determine whether this proxy is valid. This must be called from within the callback of the validate deferable.

Returns:

  • (Boolean)


34
35
36
# File 'lib/strawman/proxy.rb', line 34

def valid?
  @valid
end