Class: Blather::Stanza::Presence::Subscription
- Inherits:
-
Blather::Stanza::Presence
- Object
- Nokogiri::XML::Node
- XMPPNode
- Blather::Stanza
- Blather::Stanza::Presence
- Blather::Stanza::Presence::Subscription
- Defined in:
- lib/blather/stanza/presence/subscription.rb
Overview
# Subscription Stanza
[RFC 3921 Section 8 - Integration of Roster Items and Presence Subscriptions](xmpp.org/rfcs/rfc3921.html#rfc.section.8)
Blather handles subscription request/response through this class. It provides a set of helper methods to quickly transform the stanza into a response.
Constant Summary
Constants inherited from Blather::Stanza::Presence
Constants inherited from XMPPNode
Class Method Summary collapse
-
.new(to = nil, type = nil) ⇒ Object
Create a new Subscription stanza.
Instance Method Summary collapse
-
#approve! ⇒ self
Transform the stanza into an approve stanza makes approving requests simple.
-
#cancel! ⇒ self
Transform the stanza into a cancel stanza makes canceling simple.
- #inherit(node) ⇒ Object
-
#refuse! ⇒ self
Transform the stanza into a refuse stanza makes refusing requests simple.
-
#request! ⇒ self
Transform the stanza into a request stanza makes requests simple.
-
#request? ⇒ true, false
Check if the stanza is a request.
-
#to=(to) ⇒ Object
Set the to value on the stanza.
-
#unsubscribe! ⇒ self
Transform the stanza into an unsubscribe stanza makes unsubscribing simple.
Methods inherited from Blather::Stanza::Presence
#error?, import, #probe?, #subscribe?, #subscribed?, #type=, #unavailable?, #unsubscribe?, #unsubscribed?
Methods inherited from Blather::Stanza
#as_error, #error?, #from, #from=, handler_list, #id, #id=, next_id, register, #reply, #reply!, #to, #type, #type=
Methods inherited from XMPPNode
class_from_registration, #content_from, import, #inherit_attrs, #inspect, #namespace=, #namespace_href, #nokogiri_namespace=, #read_attr, #read_content, register, #remove_child, #remove_children, #set_content_for, #to_stanza, #write_attr
Methods inherited from Nokogiri::XML::Node
#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath
Class Method Details
.new(to = nil, type = nil) ⇒ Object
Create a new Subscription stanza
21 22 23 24 25 26 |
# File 'lib/blather/stanza/presence/subscription.rb', line 21 def self.new(to = nil, type = nil) node = super() node.to = to node.type = type node end |
Instance Method Details
#approve! ⇒ self
Transform the stanza into an approve stanza makes approving requests simple
47 48 49 50 |
# File 'lib/blather/stanza/presence/subscription.rb', line 47 def approve! self.type = :subscribed reply_if_needed! end |
#cancel! ⇒ self
Transform the stanza into a cancel stanza makes canceling simple
76 77 78 79 |
# File 'lib/blather/stanza/presence/subscription.rb', line 76 def cancel! self.type = :unsubscribed reply_if_needed! end |
#inherit(node) ⇒ Object
29 30 31 32 |
# File 'lib/blather/stanza/presence/subscription.rb', line 29 def inherit(node) inherit_attrs node.attributes self end |
#refuse! ⇒ self
Transform the stanza into a refuse stanza makes refusing requests simple
58 59 60 61 |
# File 'lib/blather/stanza/presence/subscription.rb', line 58 def refuse! self.type = :unsubscribed reply_if_needed! end |
#request! ⇒ self
Transform the stanza into a request stanza makes requests simple
85 86 87 88 |
# File 'lib/blather/stanza/presence/subscription.rb', line 85 def request! self.type = :subscribe reply_if_needed! end |
#request? ⇒ true, false
Check if the stanza is a request
93 94 95 |
# File 'lib/blather/stanza/presence/subscription.rb', line 93 def request? self.type == :subscribe end |
#to=(to) ⇒ Object
Set the to value on the stanza
37 38 39 |
# File 'lib/blather/stanza/presence/subscription.rb', line 37 def to=(to) super JID.new(to).stripped end |
#unsubscribe! ⇒ self
Transform the stanza into an unsubscribe stanza makes unsubscribing simple
67 68 69 70 |
# File 'lib/blather/stanza/presence/subscription.rb', line 67 def unsubscribe! self.type = :unsubscribe reply_if_needed! end |