Sha256: 6e1f80ac0dadaf1635287066607ac5d94386e8fa52371c72592d2d08ef462ec0

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 KB

Contents

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

    def initialize(options, app)
      @event = current_operation
      super
      @uuids = Formatter::format_uuid(options[:uuids]) unless options[:uuids].nil?
      @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?
      delete = [0, '0', false].include?(@delete) ? 0 : 1 unless @delete.nil?
      get = [0, '0', false].include?(@get) ? 0 : 1 unless @get.nil?
      update = [0, '0', false].include?(@update) ? 0 : 1 unless @update.nil?
      join = [0, '0', false].include?(@join) ? 0 : 1 unless @join.nil?

      { timestamp: @timestamp,
        w: write,
        r: read,
        m: manage,
        d: delete,
        g: get,
        u: update,
        j: join,
        ttl: @ttl }.delete_if { |_k, v| v.nil? }.merge(super(signature))
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

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