Class: BroadcastHub::StreamKeyContext
- Inherits:
-
Object
- Object
- BroadcastHub::StreamKeyContext
- Defined in:
- app/services/broadcast_hub/stream_key_context.rb
Overview
Immutable context object shared by stream key authorization and resolution.
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
Class Method Summary collapse
-
.from_connection(connection:, params: {}) ⇒ BroadcastHub::StreamKeyContext
Builds a context from an Action Cable connection and channel params.
Instance Method Summary collapse
-
#initialize(resource_name:, tenant_id:, current_user:, session_id:, params: {}) ⇒ StreamKeyContext
constructor
A new instance of StreamKeyContext.
Constructor Details
#initialize(resource_name:, tenant_id:, current_user:, session_id:, params: {}) ⇒ StreamKeyContext
Returns a new instance of StreamKeyContext.
30 31 32 33 34 35 36 37 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 30 def initialize(resource_name:, tenant_id:, current_user:, session_id:, params: {}) @resource_name = resource_name @tenant_id = tenant_id @current_user = current_user @session_id = session_id @params = (params || {}).dup.freeze freeze end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 6 def current_user @current_user end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 6 def params @params end |
#resource_name ⇒ Object (readonly)
Returns the value of attribute resource_name.
6 7 8 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 6 def resource_name @resource_name end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
6 7 8 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 6 def session_id @session_id end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
6 7 8 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 6 def tenant_id @tenant_id end |
Class Method Details
.from_connection(connection:, params: {}) ⇒ BroadcastHub::StreamKeyContext
Builds a context from an Action Cable connection and channel params.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/broadcast_hub/stream_key_context.rb', line 13 def self.from_connection(connection:, params: {}) normalized_params = normalize_params(params) new( resource_name: normalized_params[:resource], tenant_id: normalized_params[:tenant], current_user: connection_value(connection, :current_user), session_id: connection_value(connection, :session_id) || normalized_params[:session_id], params: normalized_params ) end |