module Sessions class Pause def initialize(session) @session = session end def call @session.pause! if @session.may_pause? log_event("paused") SessionChannel.broadcast_message(@session, { type: "command", action: "pause_stream" }) @session end private def log_event(type) @session.stream_events.create!(event_type: type, occurred_at: Time.current, metadata: {}) end end end