Sha256: 9c203335b4f9f6f127928e6b3cd35f77c46001071a27652c9ab24398acdb8be8

Contents?: true

Size: 844 Bytes

Versions: 4

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

module TwilioBase
  module Fake
    module TaskRouter
      class Channel
        Channel = Struct.new(:name, :attributes) do
          def sid
            @sid ||= FactoryBot.generate(channel_sid)
          end

          def capacity
            attributes[:capacity]
          end

          def update(attributes)
            self.attributes = attributes
          end
        end

        cattr_accessor :channels, :name
        self.channels = []

        def initialize(name = nil)
          self.name = name
        end

        def create(name, attributes = nil)
          channel = Channel.new(name, attributes)
          self.class.channels << channel
          channel
        end

        def fetch
          channels.detect { |channel| channel.name == name }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twilio_base-1.11.1101 spec/support/twilio_base/fake/task_router/channel.rb
twilio_base-1.11.11 spec/support/twilio_base/fake/task_router/channel.rb
twilio_base-1.9.0 spec/support/twilio_base/fake/task_router/channel.rb
twilio_base-1.8.0 spec/support/twilio_base/fake/task_router/channel.rb