Sha256: 37a404a9e9ef46be5b5dd29004da3a37157774451bf35342be2069f847947108

Contents?: true

Size: 1.06 KB

Versions: 36

Compression:

Stored size: 1.06 KB

Contents

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

      def validate!
        return if @skip_validate
        validate_action!
      end

      private

      def validate_action!
        validate_action_presence!
        validate_action_correctness!
      end

      def validate_action_presence!
        return unless @action.nil?
        raise(
          ArgumentError.new,
          ':action is required for channel registration event.'
        )
      end

      def validate_action_correctness!
        return if %i[add list_groups get remove list_namespaces].include?(@action.to_sym)
        raise(
          ArgumentError.new(
            object: self,
            message: 'Invalid :action key. Valid action keys are: :add, :list_groups, :get, :remove key'
          ),
          'Invalid :action key. Valid action keys are: :add, :list_groups, :get, :remove key'
        )
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
pubnub-4.5.0 lib/pubnub/validators/channel_registration.rb
pubnub-4.4.0 lib/pubnub/validators/channel_registration.rb
pubnub-4.3.0 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.7 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.6 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.5 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.4 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.3 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.2 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.1 lib/pubnub/validators/channel_registration.rb
pubnub-4.2.0 lib/pubnub/validators/channel_registration.rb
pubnub-4.1.6 lib/pubnub/validators/channel_registration.rb
pubnub-4.1.5 lib/pubnub/validators/channel_registration.rb
pubnub-4.1.2 lib/pubnub/validators/channel_registration.rb
pubnub-4.1.0 lib/pubnub/validators/channel_registration.rb
pubnub-4.0.28 lib/pubnub/validators/channel_registration.rb