Sha256: 9f741c5a77cfbbb7e3551b7aacf27c0d5faa3f50d9847fe57de15be9bf8a5e40

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

module Pubnub
  class Envelope

    INSTANCE_VARIABLES = [
        :channel,
        :error,
        :error_message,
        :first,
        :history_end,
        :history_start,
        :last,
        :message,
        :object,
        :payload,
        :response,
        :parsed_response,
        :response_message,
        :service,
        :status,
        :timetoken,
        :timetoken_update
    ]

    INSTANCE_VARIABLES.each do |var_name|
      attr_accessor var_name
    end

    alias_method 'msg', 'message'
    alias_method 'status_code', 'status'

    def initialize(parameters, app)
      INSTANCE_VARIABLES.each do |var_name|
        instance_variable_set("@#{var_name.to_s}", parameters[var_name])
      end
    end

    def is_last?
      @last ? true : false
    end

    def is_first?
      @first ? true : false
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pubnub-3.6.10 lib/pubnub/envelope.rb
pubnub-3.6.9 lib/pubnub/envelope.rb
pubnub-3.6.7 lib/pubnub/envelope.rb