class OEHClient::Realtime::Optimization

Constants

OPT_RESPONSE_ASSET
OPT_RESPONSE_CONTENT
OPT_RESPONSE_CONTENT_URL
OPT_RESPONSE_MIME_TYPE
OPT_RESPONSE_NAME

HASH keys based on the response data

OPT_RESPONSE_PROPOSITION
OPT_RESPONSE_RESPONSES

Attributes

content[RW]

Localized attributes equivalent to the returned Hash object in the response

content_url[RW]

Localized attributes equivalent to the returned Hash object in the response

interaction[RW]

Localized attributes equivalent to the returned Hash object in the response

mime_type[RW]

Localized attributes equivalent to the returned Hash object in the response

name[RW]

Localized attributes equivalent to the returned Hash object in the response

proposition[RW]

Localized attributes equivalent to the returned Hash object in the response

responses[RW]

Localized attributes equivalent to the returned Hash object in the response

Public Class Methods

create(interaction, properties={}) click to toggle source

—- Class Methods

# File lib/oehclient/realtime/optimization.rb, line 26
def self.create(interaction, properties={})

        one_asset = properties[OPT_RESPONSE_ASSET]

        # create a new instance of the OEHClient::Realtime::Optimization class
        optimization_instance = OEHClient::Realtime::Optimization.new()

        # assign all data attributes based on the properties object that is passed
        optimization_instance.name                    = properties[OPT_RESPONSE_NAME]                                                 if (properties.has_key?(OPT_RESPONSE_NAME))
        optimization_instance.proposition     = properties[OPT_RESPONSE_PROPOSITION]                                      if (properties.has_key?(OPT_RESPONSE_PROPOSITION))
        # map the asset data to the class instance variables
        optimization_instance.content         = CGI.unescapeHTML(one_asset[OPT_RESPONSE_CONTENT])            if (one_asset.has_key?(OPT_RESPONSE_CONTENT))
        optimization_instance.content_url     = one_asset[OPT_RESPONSE_CONTENT_URL]                                       if (one_asset.has_key?(OPT_RESPONSE_CONTENT_URL))
        optimization_instance.mime_type               = one_asset[OPT_RESPONSE_MIME_TYPE]                                  if (one_asset.has_key?(OPT_RESPONSE_MIME_TYPE))
        # map each of the respones to the response object
        optimization_instance.responses ||= Array.new
        one_asset[OPT_RESPONSE_RESPONSES].each do | asset_response |
                optimization_instance.responses << OEHClient::Realtime::Response.create(optimization_instance, asset_response)
        end
        # set the parent interaction object
        optimization_instance.interaction = interaction
        #return the new instance of the optimzation class
        optimization_instance

end