Class: RailsAiBridge::Mcp::AuthResult
- Inherits:
-
Data
- Object
- Data
- RailsAiBridge::Mcp::AuthResult
- Defined in:
- lib/rails_ai_bridge/mcp/auth_result.rb
Overview
Immutable result returned by every auth strategy. Strategies never raise for expected failures — they return an +AuthResult+ instead.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
-
.fail(error = :unauthorized) ⇒ AuthResult
Builds a failure result.
-
.ok(context = nil) ⇒ AuthResult
Builds a successful result, optionally carrying caller-provided context.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
+true+ when authentication failed.
-
#success? ⇒ Boolean
+true+ when authentication succeeded.
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context
11 12 13 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 11 def context @context end |
#error ⇒ Object (readonly)
Returns the value of attribute error
11 12 13 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 11 def error @error end |
#success ⇒ Object (readonly)
Returns the value of attribute success
11 12 13 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 11 def success @success end |
Class Method Details
.fail(error = :unauthorized) ⇒ AuthResult
Builds a failure result.
34 35 36 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 34 def self.fail(error = :unauthorized) new(success: false, context: nil, error: error) end |
.ok(context = nil) ⇒ AuthResult
Builds a successful result, optionally carrying caller-provided context. The meaning of +context+ depends on the strategy: +:static_bearer+ (static token), a decoded JWT payload Hash, a resolved user object, or +nil+. Callers that only need to gate access can ignore +context+ and check #success? only.
25 26 27 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 25 def self.ok(context = nil) new(success: true, context: context, error: nil) end |
Instance Method Details
#failure? ⇒ Boolean
Returns +true+ when authentication failed.
16 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 16 def failure? = !success |
#success? ⇒ Boolean
Returns +true+ when authentication succeeded.
13 |
# File 'lib/rails_ai_bridge/mcp/auth_result.rb', line 13 def success? = success |