Class: OStatus2::Publication

Inherits:
Object
  • Object
show all
Defined in:
lib/ostatus2/publication.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, hubs = []) ⇒ Publication

Returns a new instance of Publication.

Parameters:

  • url (String)

    Topic URL

  • hubs (Array) (defaults to: [])

    URLs of the hubs which should be notified about the update



5
6
7
8
# File 'lib/ostatus2/publication.rb', line 5

def initialize(url, hubs = [])
  @url  = url
  @hubs = hubs.map { |hub_url| Addressable::URI.parse(hub_url) }
end

Instance Method Details

#publishObject

Notifies hubs about the update to the topic URL

Raises:

  • (HTTP::Error)

    Error raised upon delivery failure

  • (OpenSSL::SSL::SSLError)

    Error raised upon SSL-related failure during delivery



13
14
15
# File 'lib/ostatus2/publication.rb', line 13

def publish
  @hubs.each { |hub| http_client.post(hub, form: { 'hub.mode' => 'publish', 'hub.url' => @url }) }
end