Module: Windoo::Mixins::DefaultConnection
- Included in:
- Windoo
- Defined in:
- lib/windoo/mixins/default_connection.rb
Overview
Module methods and aliases for dealing with the default connection This is extended into the API module
Class Method Summary collapse
-
.extended(extender) ⇒ Object
When this module is extended into a class.
Instance Method Summary collapse
-
#cnx=(connection) ⇒ APIConnection
Use the given Windoo::Connection object as the default connection, replacing the one that currently exists.
-
#connect(url = nil, **params) ⇒ String
(also: #login)
Create a new Connection object and use it as the default for all future API calls.
-
#default_connection ⇒ Windoo::Connection
(also: #cnx)
The current default Windoo::Connection instance.
-
#disconnect ⇒ Object
(also: #logout)
Disconnect the default connection.
Class Method Details
.extended(extender) ⇒ Object
When this module is extended into a class
20 21 22 |
# File 'lib/windoo/mixins/default_connection.rb', line 20 def self.extended(extender) Windoo.verbose_extend extender, self end |
Instance Method Details
#cnx=(connection) ⇒ APIConnection
Use the given Windoo::Connection object as the default connection, replacing the one that currently exists.
56 57 58 59 60 61 62 |
# File 'lib/windoo/mixins/default_connection.rb', line 56 def cnx=(connection) unless connection.is_a? Windoo::Connection raise 'Title Editor connections must be instances of Windoo::Connection' end @default_connection = connection end |
#connect(url = nil, **params) ⇒ String Also known as: login
Create a new Connection object and use it as the default for all future API calls. This will replace the existing default connection with a totally new one
41 42 43 44 45 |
# File 'lib/windoo/mixins/default_connection.rb', line 41 def connect(url = nil, **params) params[:name] ||= :default @default_connection = Windoo::Connection.new url, **params @default_connection.to_s end |
#default_connection ⇒ Windoo::Connection Also known as: cnx
The current default Windoo::Connection instance.
28 29 30 |
# File 'lib/windoo/mixins/default_connection.rb', line 28 def default_connection @default_connection ||= Windoo::Connection.new name: :default end |
#disconnect ⇒ Object Also known as: logout
Disconnect the default connection
66 67 68 |
# File 'lib/windoo/mixins/default_connection.rb', line 66 def disconnect @default_connection.disconnect if @default_connection&.connected? end |