module LogicalModel::UrlHelper::ClassMethods

adds following setters

add reader

Attributes

host[RW]
resource_path[RW]
use_ssl[RW]

Public Instance Methods

do_with_resource_path(new_path) { || ... } click to toggle source

Requests done within the block will go to new path.

@example

@resource_path # '/comments'
do_with_resource_path("users/#{@user_id}/#{@resource_path}"}/") do
  @resource_path # '/users/23/comments'
end

@param [String] new_path

# File lib/logical_model/url_helper.rb, line 84
def do_with_resource_path(new_path)
  bkp_path = @resource_path
  @resource_path = new_path
  yield
  @resource_path = bkp_path
end
force_ssl() click to toggle source

If called in class, will make al request through SSL. @example

class Client < LogicalModel
  force_ssl
  ...
end
# File lib/logical_model/url_helper.rb, line 34
def force_ssl
  @use_ssl = true
end
resource_uri(id=nil) click to toggle source

Will return path to resource @param id [String] (nil)

# File lib/logical_model/url_helper.rb, line 23
def resource_uri(id=nil)
  sufix  = (id.nil?)? "" : "/#{id}"
  "#{url_protocol_prefix}#{host}#{resource_path}#{sufix}"
end
set_resource_host(new_host) click to toggle source
# File lib/logical_model/url_helper.rb, line 45
def set_resource_host(new_host)
  @host = new_host
end
set_resource_path(new_path) click to toggle source
# File lib/logical_model/url_helper.rb, line 49
def set_resource_path(new_path)
  @resource_path = new_path
end
set_resource_url(new_host,new_path) click to toggle source

@param new_host [String] resource host. Should NOT include protocol (http) @param new_path [String] resource path in host

# File lib/logical_model/url_helper.rb, line 40
def set_resource_url(new_host,new_path)
  @host = new_host
  @resource_path = new_path
end
url_protocol_prefix() click to toggle source

@return [String]

# File lib/logical_model/url_helper.rb, line 61
def url_protocol_prefix
  (use_ssl?)? "https://" : "http://"
end
use_ssl?() click to toggle source

Default use_ssl to ssl_recommend? @return [Boolean]

# File lib/logical_model/url_helper.rb, line 56
def use_ssl?
  @use_ssl ||= ssl_recommended?
end