Class: Ably::Realtime::Push::Admin

Inherits:
Object
  • Object
show all
Includes:
Modules::AsyncWrapper, Modules::Conversions
Defined in:
lib/ably/realtime/push/admin.rb

Overview

Class providing push notification administrative functionality for registering devices and attaching to channels etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(push) ⇒ Admin

Returns a new instance of Admin


18
19
20
21
# File 'lib/ably/realtime/push/admin.rb', line 18

def initialize(push)
  @push = push
  @client = push.client
end

Instance Attribute Details

#clientObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


13
14
15
# File 'lib/ably/realtime/push/admin.rb', line 13

def client
  @client
end

#pushObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


16
17
18
# File 'lib/ably/realtime/push/admin.rb', line 16

def push
  @push
end

Instance Method Details

#channel_subscriptionsAbly::Realtime::Push::ChannelSubscriptions

Manage channel subscriptions for devices or clients


47
48
49
# File 'lib/ably/realtime/push/admin.rb', line 47

def channel_subscriptions
  @channel_subscriptions ||= ChannelSubscriptions.new(self)
end

#device_registrationsAbly::Realtime::Push::DeviceRegistrations

Manage device registrations


41
42
43
# File 'lib/ably/realtime/push/admin.rb', line 41

def device_registrations
  @device_registrations ||= DeviceRegistrations.new(self)
end

#publish(recipient, data) { ... } ⇒ Ably::Util::SafeDeferrable

Yields:

  • Block is invoked upon successful publish of the message

Returns:

Raises:

  • (ArgumentError)

28
29
30
31
32
33
34
35
36
37
# File 'lib/ably/realtime/push/admin.rb', line 28

def publish(recipient, data, &callback)
  raise ArgumentError, "Expecting a Hash object for recipient, got #{recipient.class}" unless recipient.kind_of?(Hash)
  raise ArgumentError, "Recipient data is empty. You must provide recipient details" if recipient.empty?
  raise ArgumentError, "Expecting a Hash object for data, got #{data.class}" unless data.kind_of?(Hash)
  raise ArgumentError, "Push data field is empty. You must provide attributes for the push notification" if data.empty?

  async_wrap(callback) do
    rest_push_admin.publish(recipient, data)
  end
end