Class: OpenX::Services::Session
- Inherits:
-
Object
- Object
- OpenX::Services::Session
- Defined in:
- lib/openx/services/session.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #create(user, password) ⇒ Object
- #destroy ⇒ Object
- #host ⇒ Object
-
#initialize(url) ⇒ Session
constructor
A new instance of Session.
- #recreate! ⇒ Object
- #remote ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(url) ⇒ Session
Returns a new instance of Session.
6 7 8 9 10 |
# File 'lib/openx/services/session.rb', line 6 def initialize(url) @uri = URI.parse(url) @client = XmlrpcClient.new(self.url) @id = nil end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/openx/services/session.rb', line 4 def id @id end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/openx/services/session.rb', line 4 def password @password end |
#uri ⇒ Object
Returns the value of attribute uri.
4 5 6 |
# File 'lib/openx/services/session.rb', line 4 def uri @uri end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/openx/services/session.rb', line 4 def user @user end |
Instance Method Details
#create(user, password) ⇒ Object
24 25 26 27 28 |
# File 'lib/openx/services/session.rb', line 24 def create(user, password) self.user = user self.password = password recreate! end |
#destroy ⇒ Object
36 37 38 39 40 |
# File 'lib/openx/services/session.rb', line 36 def destroy @client.call('ox.logoff', id) self.id = nil self end |
#host ⇒ Object
16 17 18 |
# File 'lib/openx/services/session.rb', line 16 def host url.sub(/#{Regexp.escape(uri.path)}$/, '') end |
#recreate! ⇒ Object
30 31 32 33 34 |
# File 'lib/openx/services/session.rb', line 30 def recreate! raise "Unable to refresh Session" unless user && password self.id = @client.call('ox.logon', user, password) self end |
#remote ⇒ Object
20 21 22 |
# File 'lib/openx/services/session.rb', line 20 def remote @remote ||= XmlrpcSessionClient.new(self) end |
#url ⇒ Object
12 13 14 |
# File 'lib/openx/services/session.rb', line 12 def url uri.to_s end |