Class: Jabber::PubSub::Configuration

Inherits:
XMPPElement show all
Defined in:
lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb

Direct Known Subclasses

NodeConfig, SubscriptionConfig

Instance Method Summary collapse

Methods inherited from XMPPElement

class_for_name_xmlns, #clone, force_xmlns, force_xmlns?, import, #initialize, name_xmlns, name_xmlns_for_class, #parent=, #set_xml_lang, #typed_add, #xml_lang, #xml_lang=

Methods inherited from REXML::Element

#==, #delete_elements, #first_element, #first_element_text, #import, import, #replace_element_text, #typed_add

Constructor Details

This class inherits a constructor from Jabber::XMPPElement

Instance Method Details

#formObject

get the underlying XData form element



14
15
16
17
18
19
20
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 14

def form
  children.each do |c|
    return c if c.kind_of?(Jabber::Dataforms::XData)
  end

  nil
end

#form=(form) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 22

def form=(form)
  children.each do |c|
    delete_element(c)
    if c.kind_of?(Jabber::Dataforms::XData)
      delete(c)
    end
  end
  add(form)
end

#form_typeObject

Implemented by NodeConfig and SubscriptionConfig



33
34
35
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 33

def form_type
  ''
end

#nodeObject



62
63
64
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 62

def node
  attributes['node']
end

#node=(node) ⇒ Object



58
59
60
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 58

def node=(node)
  attributes['node'] = node
end

#optionsObject

get a list of the configured options represented by this stanza

return
Hash

the options and their values



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 46

def options
  configured_options = {}

  if !form.nil?
    form.fields.each do |f|
      f.values.size == 1 ? configured_options[f.var] = f.values.first : configured_options[f.var] = f.values
    end
  end

  configured_options
end

#options=(options) ⇒ Object



37
38
39
40
41
# File 'lib/vendor/xmpp4r/lib/xmpp4r/pubsub/children/configuration.rb', line 37

def options=(options)
  if options
    self.form = form_for_options( form_type, options )
  end
end