Sha256: dacd4f66603ea836b213c5d0ceb4f056e068ab125f0edeb8a64641fb5e5c4f71
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module TwilioBase module Fake module Chat class Channel Channel = Struct.new(:attributes) do def friendly_name attributes[:friendly_name] end def messages TwilioBase::Fake::Chat::Message.new end def members TwilioBase::Fake::Chat::Member.new end def sid @sid ||= FactoryBot.generate(:channel_sid) end def delete TwilioBase::Fake::Chat::Channel.channels.pop end def update(update_attributes) attributes.merge! update_attributes end end cattr_accessor :channels self.channels = [] def initialize(channel_sid = nil) self.channel_sid = channel_sid end def create(attributes) self.class.channels << Channel.new(attributes) channels.last end def fetch raise ArgumentError unless matched_channel? self.class.channels.last end private attr_accessor :channel_sid def matched_channel? self.class.channels.detect do |channel| channel.sid == channel_sid end.present? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twilio_base-1.9.0 | spec/support/twilio_base/fake/chat/channel.rb |
twilio_base-1.8.0 | spec/support/twilio_base/fake/chat/channel.rb |