class Mobi::Mtld::Da::Device::ControllerHelper::DeviceApiWeb

Copyright
Author

DeviceApiWeb is the class that lets us use user's headers transparently. We do not need to explicitly pass them as parameter to the properties() method.

Public Class Methods

new(headers, cookies, settings = nil) click to toggle source
Calls superclass method Mobi::Mtld::Da::Device::DeviceApi.new
# File ../../device_api/trunk/ruby/src/lib/device_api_web.rb, line 24
def initialize headers, cookies, settings = nil
  @headers = headers
  @cookies = cookies
  super(settings)
end

Public Instance Methods

properties(user_agent_or_headers = nil, client_side_properties = nil) click to toggle source

Get known properties either transparently from the request or from the given User-Agent, headers or Client side properties.

user_agent_or_headers

User-Agent string or array of HTTP headers.

client_side_properties

String of client side properties with the

format the client side component provides.

return

Array of Property objects.

# File ../../device_api/trunk/ruby/src/lib/device_api_web.rb, line 37
def properties user_agent_or_headers = nil,
  client_side_properties = nil

  # If no UA or headers are specified, get it from the request.
  if user_agent_or_headers.nil?
    user_agent_or_headers = @headers
  end

  # If no Client side properties are specified, get it from the cookie.
  if client_side_properties.nil?
    if !@cookies.nil? && @cookies.has_key?(@settings.cookie_name)
      client_side_properties = @cookies[@settings.cookie_name]
    end
  end

  return super(user_agent_or_headers, client_side_properties)

end