Class: Blather::Stanza::PubSub::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/blather/subscriptions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(type, opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/blather/subscriptions.rb', line 7

def self.new(type, opts = {})
  new_node      = super type, nil
  new_node.to   = opts.delete(:to) || opts.delete(:host)
  new_node.from = opts.delete(:from)
  new_node.id   = opts.delete(:id)
  new_node.pubsub.add_namespace_definition("sf", SF)
  new_node.subscriptions(opts.delete(:page) || 1)
  new_node
end

Instance Method Details

#subscribedObject



28
29
30
# File 'lib/blather/subscriptions.rb', line 28

def subscribed
  (list[:subscribed] || []).map { |h| h[:node] }
end

#subscriptions(page = 1) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/blather/subscriptions.rb', line 17

def subscriptions(page = 1)
  aff = pubsub.find_first('subscriptions', self.class.registered_ns)
  unless aff
    aff = XMPPNode.new('subscriptions', self.document)
    aff["sf:page"] = page.to_s
    aff["jid"] = self.from
    self.pubsub << aff
  end
  aff
end