Sha256: c68efb5da703495975023b62c36110332b7249410bf059a174cdfefcc4dbe505

Contents?: true

Size: 910 Bytes

Versions: 14

Compression:

Stored size: 910 Bytes

Contents

# Toplevel Pubnub module.
module Pubnub
  # Holds grant functionality
  class Grant < PAM
    include Celluloid
    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

14 entries across 14 versions & 1 rubygems

Version Path
pubnub-4.0.27 lib/pubnub/events/grant.rb
pubnub-4.0.25 lib/pubnub/events/grant.rb
pubnub-4.0.23 lib/pubnub/events/grant.rb
pubnub-4.0.22 lib/pubnub/events/grant.rb
pubnub-4.0.21 lib/pubnub/events/grant.rb
pubnub-4.0.20 lib/pubnub/events/grant.rb
pubnub-4.0.19 lib/pubnub/events/grant.rb
pubnub-4.0.18 lib/pubnub/events/grant.rb
pubnub-4.0.17 lib/pubnub/events/grant.rb
pubnub-4.0.16 lib/pubnub/events/grant.rb
pubnub-4.0.15 lib/pubnub/events/grant.rb
pubnub-4.0.14 lib/pubnub/events/grant.rb
pubnub-4.0.13 lib/pubnub/events/grant.rb
pubnub-4.0.12 lib/pubnub/events/grant.rb