Class: RailsBridge::ContentRequest
- Inherits:
-
Object
- Object
- RailsBridge::ContentRequest
- Defined in:
- lib/rails_bridge/content_request.rb
Instance Attribute Summary collapse
-
#cache_timeout ⇒ Object
Returns the value of attribute cache_timeout.
-
#content_bridge ⇒ Object
Returns the value of attribute content_bridge.
-
#default_content ⇒ Object
Returns the value of attribute default_content.
-
#host ⇒ Object
Returns the value of attribute host.
-
#on_success ⇒ Object
Returns the value of attribute on_success.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#url ⇒ Object
We don’t include the params in the URL, because Typhoeus::Request takes them as a separate argument.
Instance Method Summary collapse
- #get_remote_content(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ ContentRequest
constructor
Options: * :default_content - Content to be returned in test mode or when the remote server is unavailable * :request_timeout - Maximum time to wait for successful response in ms * :cache_timeout - TTL expiry for cache in seconds - nil or 0 will prevent caching * :protocol - Protocol of remote server (http|https).
Constructor Details
#initialize(options = {}) ⇒ ContentRequest
Options:
-
:default_content - Content to be returned in test mode or when the remote server is unavailable
-
:request_timeout - Maximum time to wait for successful response in ms
-
:cache_timeout - TTL expiry for cache in seconds - nil or 0 will prevent caching
-
:protocol - Protocol of remote server (http|https). Default is ‘http’
-
:host - Host of remote server.
-
:port - Port of remote server. Default is 80.
-
:path - Path for remote request. Default is ‘/’
-
:params - URL query params for remote request.
-
:fragment - URL part after the ‘#’ for remote request.
-
:url - Explicit URL for remote request.
if the :url option is passed, the :protocol, :host, :port, :path, :params, and :fragment options are ignored
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_bridge/content_request.rb', line 21 def initialize ={} if url = [:url] self.url = url else self.protocol = [:protocol] self.host = [:host] self.port = [:port] self.path = [:path] self.params = [:params] end self.default_content = [:default_content] self.request_timeout = [:request_timeout] self.cache_timeout = [:cache_timeout] end |
Instance Attribute Details
#cache_timeout ⇒ Object
Returns the value of attribute cache_timeout.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def cache_timeout @cache_timeout end |
#content_bridge ⇒ Object
Returns the value of attribute content_bridge.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def content_bridge @content_bridge end |
#default_content ⇒ Object
Returns the value of attribute default_content.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def default_content @default_content end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def host @host end |
#on_success ⇒ Object
Returns the value of attribute on_success.
6 7 8 |
# File 'lib/rails_bridge/content_request.rb', line 6 def on_success @on_success end |
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def protocol @protocol end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
5 6 7 |
# File 'lib/rails_bridge/content_request.rb', line 5 def request_timeout @request_timeout end |
#url ⇒ Object
We don’t include the params in the URL, because Typhoeus::Request takes them as a separate argument
55 56 57 |
# File 'lib/rails_bridge/content_request.rb', line 55 def url @url end |
Instance Method Details
#get_remote_content(options = {}) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/rails_bridge/content_request.rb', line 59 def get_remote_content( ={} ) if self.content_bridge self.content_bridge.get_remote_content( self, ) else RailsBridge::ContentBridge.get_remote_content( self, ) end end |