Sha256: 5c355e8549a4d339e499be374c012b9bd904dfd5202cf88f0885373aa251cc21

Contents?: true

Size: 915 Bytes

Versions: 9

Compression:

Stored size: 915 Bytes

Contents

# Toplevel Pubnub module.
module Pubnub
  # Holds grant functionality
  class Grant < PAM
    include Concurrent::Async
    include Pubnub::Validator::Grant

    def initialize(options, app)
      @event = :grant
      super
      @ttl ||= Pubnub::Constants::DEFAULT_TTL
    end

    private

    def current_operation
      Pubnub::Constants::OPERATION_GRANT
    end

    def parameters(signature = false)
      write = [0, '0', false].include?(@write) ? 0 : 1
      read = [0, '0', false].include?(@read) ? 0 : 1
      manage = [0, '0', false].include?(@manage) ? 0 : 1 # unless @group.blank?

      { timestamp: @timestamp,
        w: write,
        r: read,
        m: manage,
        ttl: @ttl }.delete_if { |_k, v| v.nil? }.merge(super(signature))
    end

    def path
      '/' + [
        'v1',
        'auth',
        'grant',
        'sub-key',
        @subscribe_key
      ].join('/')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pubnub-4.2.3 lib/pubnub/events/grant.rb
pubnub-4.2.2 lib/pubnub/events/grant.rb
pubnub-4.2.1 lib/pubnub/events/grant.rb
pubnub-4.2.0 lib/pubnub/events/grant.rb
pubnub-4.1.6 lib/pubnub/events/grant.rb
pubnub-4.1.5 lib/pubnub/events/grant.rb
pubnub-4.1.2 lib/pubnub/events/grant.rb
pubnub-4.1.0 lib/pubnub/events/grant.rb
pubnub-4.0.28 lib/pubnub/events/grant.rb