Class: Blather::Stanza::PubSub::Affiliations
Constant Summary
Constants inherited
from Iq
Iq::VALID_TYPES
Constants inherited
from XMPPNode
XMPPNode::BASE_NAMES
Class Method Summary
collapse
Instance Method Summary
collapse
import, #pubsub
Methods inherited from Iq
import, #type=
#as_error, attribute_helpers_for, #from, handler_list, next_id, register, #reply, #reply!, #to
Methods inherited from XMPPNode
attribute_accessor, attribute_reader, attribute_writer, class_from_registration, content_attr_accessor, content_attr_reader, content_attr_writer, #content_from, import, #inherit_attrs, #namespace=, #namespace_href, #nokogiri_namespace=, register, #remove_child, #remove_children, #set_content_for, #to_stanza
#[]=, #attr_set, #find_first, #nokogiri_xpath, #xpath
Class Method Details
.new(type = nil, host = nil) ⇒ Object
11
12
13
14
15
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 11
def self.new(type = nil, host = nil)
new_node = super
new_node.affiliations
new_node
end
|
Instance Method Details
#affiliations ⇒ Object
24
25
26
27
28
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 24
def affiliations
aff = pubsub.find_first('pubsub_ns:affiliations', :pubsub_ns => self.class.registered_ns)
self.pubsub << (aff = XMPPNode.new('affiliations', self.document)) unless aff
aff
end
|
#each(&block) ⇒ Object
30
31
32
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 30
def each(&block)
list.each &block
end
|
#inherit(node) ⇒ Object
Kill the affiliations node before running inherit
19
20
21
22
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 19
def inherit(node)
affiliations.remove
super
end
|
38
39
40
41
42
43
44
45
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 38
def list
items = affiliations.find('//ns:affiliation', :ns => self.class.registered_ns)
items.inject({}) do |hash, item|
hash[item[:affiliation].to_sym] ||= []
hash[item[:affiliation].to_sym] << item[:node]
hash
end
end
|
34
35
36
|
# File 'lib/blather/stanza/pubsub/affiliations.rb', line 34
def size
list.size
end
|