Class: RExchange::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/rexchange/credentials.rb

Overview

Credentials are passed around between Folders to emulate a stateful connection with the RExchange::Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, username = nil, password = nil) ⇒ Credentials

You must pass a uri, a username and a password


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rexchange/credentials.rb', line 11

def initialize(uri, username = nil, password = nil)
  @uri = URI.parse(uri)
  @use_ssl = (@uri.scheme.downcase == 'https')
  @user = @uri.userinfo ? @user.userinfo.split(':')[0] : username
  @password = @uri.userinfo ? @user.userinfo.split(':')[1] : password
  @port = @uri.port || @uri.default_port
        
  if block_given?
    yield self
  else
    return self
  end
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password


8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def password
  @password
end

#uriObject (readonly)

Returns the value of attribute uri


8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def uri
  @uri
end

#userObject (readonly)

Returns the value of attribute user


8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def user
  @user
end

Instance Method Details

#use_ssl?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/rexchange/credentials.rb', line 25

def use_ssl?
  @use_ssl
end