Sha256: ed89217ea642c71483b425ee8a1913493ed8090644cf9fbac728a30aab7e5b56

Contents?: true

Size: 1.26 KB

Versions: 28

Compression:

Stored size: 1.26 KB

Contents

# Toplevel Pubnub module.
module Pubnub
  # Validator module that holds all validators modules
  module Validator
    # Validator for History event
    module MessageCounts
      include CommonValidator

      def validate!
        return if @skip_validate

        validate_channel!
      end

      private

      def validate_channel!
        chans = @channel
        chans = @channel.split(',') if @channel.is_a? String
        tokens = @timetokens

        if tokens.length.zero?
          raise(
            ArgumentError.new(
              object: self,
              message: 'channel_timetokens: must contain single or multiple timetokens equaling to number of channels given must be provided.'
            ),
            'channel_timetokens: must contain single or multiple timetokens equaling to number of channels given must be provided.'
          )
        elsif tokens.length > 1 && tokens.length != chans.length
          raise(
            ArgumentError.new(
              object: self,
              message: 'Number of channel_timetokens: elements must be 1 or same as number of provided channels.'
            ),
            'Number of channel_timetokens: elements must be 1 or same as number of provided channels.'
          )
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
pubnub-5.3.5 lib/pubnub/validators/message_counts.rb
pubnub-5.3.4 lib/pubnub/validators/message_counts.rb
pubnub-5.3.3 lib/pubnub/validators/message_counts.rb
pubnub-5.3.2 lib/pubnub/validators/message_counts.rb
pubnub-5.3.1 lib/pubnub/validators/message_counts.rb
pubnub-5.3.0 lib/pubnub/validators/message_counts.rb
pubnub-5.2.2 lib/pubnub/validators/message_counts.rb
pubnub-5.2.1 lib/pubnub/validators/message_counts.rb
pubnub-5.2.0 lib/pubnub/validators/message_counts.rb
pubnub-5.1.2 lib/pubnub/validators/message_counts.rb
pubnub-5.1.1 lib/pubnub/validators/message_counts.rb
pubnub-5.1.0 lib/pubnub/validators/message_counts.rb
pubnub-5.0.0 lib/pubnub/validators/message_counts.rb
pubnub-4.8.0 lib/pubnub/validators/message_counts.rb
pubnub-4.7.1 lib/pubnub/validators/message_counts.rb
pubnub-4.7.0 lib/pubnub/validators/message_counts.rb
pubnub-4.6.2 lib/pubnub/validators/message_counts.rb
pubnub-4.6.1 lib/pubnub/validators/message_counts.rb
pubnub-4.6.0 lib/pubnub/validators/message_counts.rb
pubnub-4.5.0 lib/pubnub/validators/message_counts.rb