Sha256: c1a218a6cd12398848a5387277ae07e81a5b0f49bb3b5da9cac5da03a6e01c32

Contents?: true

Size: 479 Bytes

Versions: 3

Compression:

Stored size: 479 Bytes

Contents

# frozen_string_literal: true

require 'whatup/server/models/application_record'

module Whatup
  module Server
    class Room < ApplicationRecord
      has_many :clients

      validates :name, uniqueness: true

      def drop_client! client
        client.update! room_id: nil
      end

      def broadcast except: nil
        if except
          clients.where.not id: except.id
        else
          clients
        end.each { |c| c.puts yield }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
whatup-0.3.1 lib/whatup/server/models/room.rb
whatup-0.3.0 lib/whatup/server/models/room.rb
whatup-0.2.5 lib/whatup/server/models/room.rb