Class: ActionMCP::Gateway
- Inherits:
-
Object
- Object
- ActionMCP::Gateway
- Defined in:
- lib/action_mcp/gateway.rb
Direct Known Subclasses
Class Method Summary collapse
-
.identified_by(*klasses) ⇒ Object
pluck in one or many GatewayIdentifier classes.
- .identifier_classes ⇒ Object
Instance Method Summary collapse
-
#call ⇒ Object
called by your rack/websocket layer.
-
#configure_session(session) ⇒ Object
Hook to persist gateway context on the session.
-
#initialize(request) ⇒ Gateway
constructor
A new instance of Gateway.
Constructor Details
#initialize(request) ⇒ Gateway
Returns a new instance of Gateway.
18 19 20 |
# File 'lib/action_mcp/gateway.rb', line 18 def initialize(request) @request = request end |
Class Method Details
.identified_by(*klasses) ⇒ Object
pluck in one or many GatewayIdentifier classes
9 10 11 |
# File 'lib/action_mcp/gateway.rb', line 9 def identified_by(*klasses) @identifier_classes = klasses.flatten end |
.identifier_classes ⇒ Object
13 14 15 |
# File 'lib/action_mcp/gateway.rb', line 13 def identifier_classes @identifier_classes || [] end |
Instance Method Details
#call ⇒ Object
called by your rack/websocket layer
23 24 25 26 27 28 |
# File 'lib/action_mcp/gateway.rb', line 23 def call identities = authenticate! assign_identities(identities) apply_profile_from_authentication(identities) self end |
#configure_session(session) ⇒ Object
Hook to persist gateway context on the session. Called on every authenticated request. Implementations should be idempotent.
Example:
class ApplicationGateway < ActionMCP::Gateway
def configure_session(session)
session.session_data = {
"user_id" => user.id,
"company_id" => user.company_id
}
end
end
45 46 47 |
# File 'lib/action_mcp/gateway.rb', line 45 def configure_session(session) # Default: no-op. Override in subclass. end |