Class: Blather::DSL::PubSub
- Inherits:
-
Object
- Object
- Blather::DSL::PubSub
- Defined in:
- lib/blather/client/dsl/pubsub.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
-
#affiliations(host = nil) {|Hash| ... } ⇒ Object
Retrieve Affiliations.
-
#create(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Create a node.
-
#delete(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Delete a node.
-
#initialize(client, host) ⇒ PubSub
constructor
Create a new pubsub DSL.
-
#items(path, list = [], max = nil, host = nil) {|Array<Blather::Stanza::PubSub::PubSubItem>| ... } ⇒ Object
Retrieve items for a node.
-
#node(path, host = nil) {|Blather::Stanza::DiscoInfo| ... } ⇒ Object
Discover node information.
-
#nodes(path = nil, host = nil) {|Array<Blather::Stanza::DiscoItems::Item>| ... } ⇒ Object
Discover Nodes.
-
#publish(node, payload, host = nil) {|Blather::Stanza| ... } ⇒ Object
Publish an item to a node.
-
#purge(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Purge all node items.
-
#retract(node, ids = [], host = nil) {|Blather::Stanza| ... } ⇒ Object
Delete items from a node.
-
#subscribe(node, jid = nil, host = nil) {|Blather::Stanza| ... } ⇒ Object
Subscribe to a node.
-
#subscriptions(host = nil) {|Hash| ... } ⇒ Object
Retrieve Subscriptions.
-
#unsubscribe(node, jid = nil, host = nil) {|Blather::Stanza| ... } ⇒ Object
Unsubscribe from a node.
Constructor Details
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/blather/client/dsl/pubsub.rb', line 5 def host @host end |
Instance Method Details
#affiliations(host = nil) {|Hash| ... } ⇒ Object
Retrieve Affiliations
20 21 22 |
# File 'lib/blather/client/dsl/pubsub.rb', line 20 def affiliations(host = nil, &callback) request Stanza::PubSub::Affiliations.new(:get, send_to(host)), :list, callback end |
#create(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Create a node
123 124 125 126 |
# File 'lib/blather/client/dsl/pubsub.rb', line 123 def create(node, host = nil) stanza = Stanza::PubSub::Create.new(:set, send_to(host), node) request(stanza) { |n| yield n if block_given? } end |
#delete(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Delete a node
143 144 145 146 |
# File 'lib/blather/client/dsl/pubsub.rb', line 143 def delete(node, host = nil) stanza = Stanza::PubSubOwner::Delete.new(:set, send_to(host), node) request(stanza) { |n| yield n if block_given? } end |
#items(path, list = [], max = nil, host = nil) {|Array<Blather::Stanza::PubSub::PubSubItem>| ... } ⇒ Object
Retrieve items for a node
62 63 64 65 66 67 68 |
# File 'lib/blather/client/dsl/pubsub.rb', line 62 def items(path, list = [], max = nil, host = nil, &callback) request( Stanza::PubSub::Items.request(send_to(host), path, list, max), :items, callback ) end |
#node(path, host = nil) {|Blather::Stanza::DiscoInfo| ... } ⇒ Object
Discover node information
49 50 51 52 53 |
# File 'lib/blather/client/dsl/pubsub.rb', line 49 def node(path, host = nil, &callback) stanza = Stanza::DiscoInfo.new(:get, path) stanza.to = send_to(host) request stanza, nil, callback end |
#nodes(path = nil, host = nil) {|Array<Blather::Stanza::DiscoItems::Item>| ... } ⇒ Object
Discover Nodes
37 38 39 40 41 42 |
# File 'lib/blather/client/dsl/pubsub.rb', line 37 def nodes(path = nil, host = nil, &callback) path ||= '/' stanza = Stanza::DiscoItems.new(:get, path) stanza.to = send_to(host) request stanza, :items, callback end |
#publish(node, payload, host = nil) {|Blather::Stanza| ... } ⇒ Object
Publish an item to a node
102 103 104 105 |
# File 'lib/blather/client/dsl/pubsub.rb', line 102 def publish(node, payload, host = nil) stanza = Stanza::PubSub::Publish.new(send_to(host), node, :set, payload) request(stanza) { |n| yield n if block_given? } end |
#purge(node, host = nil) {|Blather::Stanza| ... } ⇒ Object
Purge all node items
133 134 135 136 |
# File 'lib/blather/client/dsl/pubsub.rb', line 133 def purge(node, host = nil) stanza = Stanza::PubSubOwner::Purge.new(:set, send_to(host), node) request(stanza) { |n| yield n if block_given? } end |
#retract(node, ids = [], host = nil) {|Blather::Stanza| ... } ⇒ Object
Delete items from a node
113 114 115 116 |
# File 'lib/blather/client/dsl/pubsub.rb', line 113 def retract(node, ids = [], host = nil) stanza = Stanza::PubSub::Retract.new(send_to(host), node, :set, ids) request(stanza) { |n| yield n if block_given? } end |
#subscribe(node, jid = nil, host = nil) {|Blather::Stanza| ... } ⇒ Object
Subscribe to a node
Defaults to the stripped current JID
77 78 79 80 81 |
# File 'lib/blather/client/dsl/pubsub.rb', line 77 def subscribe(node, jid = nil, host = nil) jid ||= client.jid.stripped stanza = Stanza::PubSub::Subscribe.new(:set, send_to(host), node, jid) request(stanza) { |n| yield n if block_given? } end |
#subscriptions(host = nil) {|Hash| ... } ⇒ Object
Retrieve Subscriptions
28 29 30 |
# File 'lib/blather/client/dsl/pubsub.rb', line 28 def subscriptions(host = nil, &callback) request Stanza::PubSub::Subscriptions.new(:get, send_to(host)), :list, callback end |
#unsubscribe(node, jid = nil, host = nil) {|Blather::Stanza| ... } ⇒ Object
Unsubscribe from a node
Defaults to the stripped current JID
90 91 92 93 94 |
# File 'lib/blather/client/dsl/pubsub.rb', line 90 def unsubscribe(node, jid = nil, host = nil) jid ||= client.jid.stripped stanza = Stanza::PubSub::Unsubscribe.new(:set, send_to(host), node, jid) request(stanza) { |n| yield n if block_given? } end |