Class: Clacky::Mcp::ConnectionManager
- Inherits:
-
Object
- Object
- Clacky::Mcp::ConnectionManager
- Defined in:
- lib/clacky/mcp/connection_manager.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
-
#initialize(server_name:, home: Dir.home, working_dir: Dir.pwd, session_factory: nil) ⇒ ConnectionManager
constructor
A new instance of ConnectionManager.
- #login ⇒ Object
- #logout ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(server_name:, home: Dir.home, working_dir: Dir.pwd, session_factory: nil) ⇒ ConnectionManager
Returns a new instance of ConnectionManager.
14 15 16 17 18 19 20 21 |
# File 'lib/clacky/mcp/connection_manager.rb', line 14 def initialize(server_name:, home: Dir.home, working_dir: Dir.pwd, session_factory: nil) @server_name = server_name.to_s @home = File.(home) @working_dir = working_dir && File.(working_dir) @session_factory = session_factory || lambda do |_config, store, manager| OAuth::Session.new(store: store, manager: manager) end end |
Instance Method Details
#login ⇒ Object
23 24 25 26 27 28 |
# File 'lib/clacky/mcp/connection_manager.rb', line 23 def login session.login safe_status rescue OAuth::AuthorizationManager::Error, OAuth::Session::Error, OAuth::CredentialStore::Error => e raise Error, e. end |
#logout ⇒ Object
36 37 38 39 40 41 |
# File 'lib/clacky/mcp/connection_manager.rb', line 36 def logout session.logout { "server" => @server_name, "connected" => false } rescue OAuth::Session::Error, OAuth::CredentialStore::Error => e raise Error, e. end |
#status ⇒ Object
30 31 32 33 34 |
# File 'lib/clacky/mcp/connection_manager.rb', line 30 def status safe_status rescue OAuth::CredentialStore::Error => e raise Error, e. end |