Class: Blather::Stanza::PubSubOwner::Purge

Inherits:
Blather::Stanza::PubSubOwner show all
Defined in:
lib/blather/stanza/pubsub_owner/purge.rb

Overview

# PubSubOwner Purge Stanza

[XEP-0060 Section 8.5 - Purge All Node Items](xmpp.org/extensions/xep-0060.html#owner-purge)

Constant Summary

Constants inherited from Iq

Iq::VALID_TYPES

Constants inherited from XMPPNode

XMPPNode::BASE_NAMES

Instance Attribute Summary

Attributes inherited from Blather::Stanza

#handler_hierarchy

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Blather::Stanza::PubSubOwner

import, #inherit, #pubsub

Methods inherited from Iq

#error?, #get?, import, #reply!, #result?, #set?, #type=

Methods inherited from Blather::Stanza

#as_error, #error?, #from, #from=, handler_list, #id, #id=, #initialize, next_id, register, #reply, #reply!, #to, #to=, #type, #type=

Methods inherited from XMPPNode

class_from_registration, #decorate, decorator_modules, import, parse, register, #to_stanza

Constructor Details

This class inherits a constructor from Blather::Stanza

Class Method Details

.new(type = :set, host = nil, node = nil) ⇒ Object

Create a new purge stanza

Parameters:

  • type (Blather::Stanza::Iq::VALID_TYPES) (defaults to: :set)

    the IQ stanza type

  • host (String) (defaults to: nil)

    the host to send the request to

  • node (String) (defaults to: nil)

    the name of the node to purge



18
19
20
21
22
# File 'lib/blather/stanza/pubsub_owner/purge.rb', line 18

def self.new(type = :set, host = nil, node = nil)
  new_node = super(type, host)
  new_node.node = node
  new_node
end

Instance Method Details

#nodeString

Get the name of the node to delete

Returns:

  • (String)


27
28
29
# File 'lib/blather/stanza/pubsub_owner/purge.rb', line 27

def node
  purge_node[:node]
end

#node=(node) ⇒ Object

Set the name of the node to delete

Parameters:

  • node (String)


34
35
36
# File 'lib/blather/stanza/pubsub_owner/purge.rb', line 34

def node=(node)
  purge_node[:node] = node
end

#purge_nodeBlather::XMPPNode

Get or create the actual purge node on the stanza

Returns:



41
42
43
44
45
46
47
# File 'lib/blather/stanza/pubsub_owner/purge.rb', line 41

def purge_node
  unless purge_node = pubsub.find_first('ns:purge', :ns => self.class.registered_ns)
    self.pubsub << (purge_node = XMPPNode.new('purge', self.document))
    purge_node.namespace = self.pubsub.namespace
  end
  purge_node
end