Class: Hootenanny::Hub

Inherits:
Object
  • Object
show all
Defined in:
lib/hootenanny/hub.rb

Class Method Summary collapse

Class Method Details

.broadcastObject



97
98
99
100
101
102
103
104
105
# File 'lib/hootenanny/hub.rb', line 97

def self.broadcast
  Hootenanny::PublishNotification.each_unprocessed do |notification|
    if Hootenanny::Correspondent.broadcast(notification.topic)
      notification.process
    else
      Hootenanny::PublishNotificationExpirationPolicy.apply notification
    end
  end
end

.notify_of_publication(request) ⇒ Object

Public: Notifies the hub that topic has had its content updated since the last time the content was pulled.

This method is idempotent. If a notification already exists, it will be reused and sent back without notifying the user of that fact.

If all is ok, a notification will be created, if not, an error with details will be returned.

request - Any object which responds to #apply. Typically this should be

a Hootenanny::Request::PublishNotification.

Returns an indeterminate object (based on the request passed in) but is

typically a Hootenanny::PublishNotification.

Raises Hootenanny::PublishNotificationError with a message describing the

problem


93
94
95
# File 'lib/hootenanny/hub.rb', line 93

def self.notify_of_publication(request)
  request.apply
end

.request(options = {}) ⇒ Object

Public: Generates a request of varying types which can be used to perform actions such as subscribing to a topic.

This method has zero side-effects and is only utilized to prepare a request.

options - A Hash of options which can vary based on the type of request that

is being... requested.

:type     - The type of request (eg: :subscription)
:action   - The action to be performed when the request is
            applied. This can vary based on the type of request
            being created.
:callback - Used for :subscription requests.  Is a URI which
            should be notified when the topic that it is
            interested in, is updated.
:topic    - Used for :subscription requests.  Is a URI which
            represents all of the items which the subscriber is
            interested in.

Returns an indeterminate object (based on the type of request that is

generated, but all of them will inherit from Hootenanny::Request

Raises a Hootenanny::Request::BuildError if any problems are encountered



131
132
133
# File 'lib/hootenanny/hub.rb', line 131

def self.request(options = {})
  Hootenanny::Request.build(options)
end

.subscribe(request) ⇒ Object

Public: Subscribes a subscriber to a topic based on the information defined in a subscription request.

This method is idempotent. If a subscription already exists, it will be reused and sent back without notifying the user of that fact.

If the subscription does not already exist, it will be verified against the callback URL. If all is ok, a subscription will be created, if not, an error with details will be returned.

request - Any object which responds to #apply. Typically this should be

a Hootenanny::Request::Subscription.

Returns an indeterminate object (based on the request passed in) but is

typically a Hootenanny::Subscription.

Raises Hootenanny::SubscriptionAssignmentError with a message describing the

problem


71
72
73
# File 'lib/hootenanny/hub.rb', line 71

def self.subscribe(request)
  request.apply
end