Sha256: a7498cc938257f411768a01d7bc1906c475f3bb9bb90524d4822917b7ab147e5

Contents?: true

Size: 1.36 KB

Versions: 8

Compression:

Stored size: 1.36 KB

Contents

module Ably::Models
  # Convert token details argument to a {ChannelDetails} object
  #
  # @param attributes (see #initialize)
  #
  # @return [ChannelDetails]
  #
  def self.ChannelDetails(attributes)
    case attributes
    when ChannelDetails
      return attributes
    else
      ChannelDetails.new(attributes)
    end
  end

  # Contains the details of a {Ably::Models::Rest::Channel} or {Ably::Models::Realtime::Channel} object
  # such as its ID and {Ably::Models::ChannelStatus}.
  #
  class ChannelDetails
    extend Ably::Modules::Enum
    extend Forwardable
    include Ably::Modules::ModelCommon

    # The attributes of ChannelDetails
    #
    # @spec CHD2
    #
    attr_reader :attributes

    alias_method :to_h, :attributes

    # Initialize a new ChannelDetails
    #
    def initialize(attrs)
      @attributes = IdiomaticRubyWrapper(attrs.clone)
    end

    # The identifier of the channel
    #
    # @spec CHD2a
    #
    # @return [String]
    #
    def channel_id
      attributes[:channel_id]
    end

    # The identifier of the channel
    #
    # @spec CHD2a
    #
    # @return [String]
    #
    def name
      attributes[:name]
    end

    # A {Ably::Models::ChannelStatus} object.
    #
    # @spec CHD2b
    #
    # @return [Ably::Models::ChannelStatus, nil]
    #
    def status
      Ably::Models::ChannelStatus(attributes[:status])
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/lib/ably/models/channel_details.rb
ably-1.2.7 lib/ably/models/channel_details.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/lib/ably/models/channel_details.rb
ably-1.2.6 lib/ably/models/channel_details.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/lib/ably/models/channel_details.rb
ably-1.2.4 lib/ably/models/channel_details.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/lib/ably/models/channel_details.rb
ably-1.2.3 lib/ably/models/channel_details.rb