class OEHClient::Meta::Session

Attributes

cookies[RW]
space[RW]

Public Class Methods

attach(space) click to toggle source
# File lib/oehclient/meta/session.rb, line 5
def self.attach(space)
        # post the login request
        response = OEHClient.post(space.login_url, nil, :payload => space.meta_credentials)
        # create a new session object
        session_instance = OEHClient::Meta::Session.new()
        # assign the space object
        session_instance.space                = space
        # store the cookies if they are returned in the response
        session_instance.cookies      = response[:cookies]  if (response.has_key?(:cookies))
        # return the session instance
        session_instance
end

Public Instance Methods

detach() click to toggle source
# File lib/oehclient/meta/session.rb, line 18
def detach()
        # construct a header object, merging cookies (if present) wit the default JSON header
        header = Hash.new
        header.merge!(:cookies => @cookies)                                                           unless (@cookies.blank?)
        header.merge!(OEHClient::Helper::Request.default_JSON_header)
        # post the logout request
        OEHClient.post(@space.logout_url, nil, :header => header)
        # remove the cookies if the logout is posted successfully
        @cookies = nil        
end
workspace(site_key) click to toggle source

retrieve the workspace meta-data object from the thinstance in realtime

# File lib/oehclient/meta/session.rb, line 30
def workspace(site_key)
        # get the workspace object using the site key, the host value, and the exisitng cookies
        OEHClient::Meta::Workspace.find_by_key(self, site_key)
end