Class: Sword2Ruby::Connection
- Inherits:
-
Atom::HTTP
- Object
- Atom::HTTP
- Sword2Ruby::Connection
- Defined in:
- lib/sword2ruby/connection.rb
Overview
The Connection class inherits from the Atom::HTTP class to ensure authentication credentials are used on Sword operations.
Please see the atom-tools documentation for a complete list of attributes and methods (including post, get, put, delete etc).
Instance Attribute Summary collapse
-
#use_authentication ⇒ Object
readonly
Boolean value indicating whether authentication is used.
-
#user_credentials ⇒ Object
readonly
The Sword2Ruby::User credentials object this connection is using, or nil for anonymous communication.
Instance Method Summary collapse
-
#initialize(user_credentials = nil) ⇒ Connection
constructor
- Creates a new Connection object ===Parameters user_credentials
-
(optional) a Sword2Ruby::User object with the username and password.
Constructor Details
#initialize(user_credentials = nil) ⇒ Connection
Creates a new Connection object
Parameters
- user_credentials
-
(optional) a Sword2Ruby::User object with the username and password
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sword2ruby/connection.rb', line 19 def initialize(user_credentials = nil) unless user_credentials.nil? Utility.check_argument_class('user_credentials', user_credentials, User) end @user_credentials = user_credentials @use_authentication = @user_credentials && @user_credentials.username && @user_credentials.password super() #initialize the base (Atom::HTTP) class if @use_authentication self.user = @user_credentials.username self.pass = @user_credentials.password self.always_auth = :basic end end |
Instance Attribute Details
#use_authentication ⇒ Object (readonly)
Boolean value indicating whether authentication is used
14 15 16 |
# File 'lib/sword2ruby/connection.rb', line 14 def use_authentication @use_authentication end |
#user_credentials ⇒ Object (readonly)
The Sword2Ruby::User credentials object this connection is using, or nil for anonymous communication
11 12 13 |
# File 'lib/sword2ruby/connection.rb', line 11 def user_credentials @user_credentials end |