Sha256: 8265664ce251e84332c1f6aa92567d0cb3b044516859abe357b6fcb9dbd14c43

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

class OEHClient::Meta::Session

	attr_accessor :cookies, :space

	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

	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

	# retrieve the workspace meta-data object from the thinstance in realtime
	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


end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
oeh-client-2.2.9 lib/oehclient/meta/session.rb
oeh-client-2.2.8 lib/oehclient/meta/session.rb
oeh-client-2.2.7 lib/oehclient/meta/session.rb
oeh-client-2.2.6 lib/oehclient/meta/session.rb
oeh-client-2.2.5 lib/oehclient/meta/session.rb
oeh-client-2.2.4 lib/oehclient/meta/session.rb
oeh-client-2.2.3 lib/oehclient/meta/session.rb
oeh-client-2.2.1 lib/oehclient/meta/session.rb
oeh-client-2.2.0 lib/oehclient/meta/session.rb
oeh-client-2.1.0 lib/oehclient/meta/session.rb
oeh-client-2.0.3 lib/oehclient/meta/session.rb
oeh-client-2.0.2 lib/oehclient/meta/session.rb
oeh-client-2.0.1 lib/oehclient/meta/session.rb
oeh-client-1.1.0 lib/oehclient/meta/session.rb