Class: Lotus::Publisher
- Inherits:
-
Object
- Object
- Lotus::Publisher
- Defined in:
- lib/lotus/publisher.rb
Instance Attribute Summary collapse
-
#hubs ⇒ Object
readonly
The array of feed urls used to push content.
-
#url ⇒ Object
readonly
The url of the feed.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Publisher
constructor
Creates a representation of a Publisher entity.
-
#ping_hubs ⇒ Object
Will ping PuSH hubs so that they know there is new/updated content.
Constructor Details
#initialize(options = {}) ⇒ Publisher
Creates a representation of a Publisher entity.
options:
:feed => A feed to use to populate the other fields.
:url => The url of the feed that will be published.
:hubs => An array of hub urls that are used to handle load
balancing pushes of new data. Default: []
19 20 21 22 23 24 25 26 27 |
# File 'lib/lotus/publisher.rb', line 19 def initialize( = {}) if [:feed] @url = [:feed].url @hubs = [:feed].hubs end @url ||= [:url] @hubs ||= [:hubs] || [] end |
Instance Attribute Details
#hubs ⇒ Object (readonly)
The array of feed urls used to push content. Default: []
10 11 12 |
# File 'lib/lotus/publisher.rb', line 10 def hubs @hubs end |
#url ⇒ Object (readonly)
The url of the feed.
7 8 9 |
# File 'lib/lotus/publisher.rb', line 7 def url @url end |
Instance Method Details
#ping_hubs ⇒ Object
Will ping PuSH hubs so that they know there is new/updated content. The hub should respond by pulling the new data and then sending it to subscribers.
32 33 34 35 36 37 38 |
# File 'lib/lotus/publisher.rb', line 32 def ping_hubs @hubs.each do |hub_url| res = Net::HTTP.post_form(URI.parse(hub_url), { 'hub.mode' => 'publish', 'hub.url' => @topic_url }) end end |