Class: Vines::Stanza::Iq

Inherits:
Vines::Stanza show all
Defined in:
lib/vines/stanza/iq.rb,
lib/vines/stanza/iq/auth.rb,
lib/vines/stanza/iq/ping.rb,
lib/vines/stanza/iq/error.rb,
lib/vines/stanza/iq/query.rb,
lib/vines/stanza/iq/vcard.rb,
lib/vines/stanza/iq/result.rb,
lib/vines/stanza/iq/roster.rb,
lib/vines/stanza/iq/session.rb,
lib/vines/stanza/iq/version.rb,
lib/vines/stanza/iq/register.rb,
lib/vines/stanza/iq/disco_info.rb,
lib/vines/stanza/iq/disco_items.rb,
lib/vines/stanza/iq/private_storage.rb

Direct Known Subclasses

Error, Ping, Query, Result, Session, Vcard, PubSub

Defined Under Namespace

Classes: Auth, DiscoInfo, DiscoItems, Error, Ping, PrivateStorage, Query, Register, Result, Roster, Session, Vcard, Version

Constant Summary collapse

VALID_TYPES =
%w[get set result error].freeze

Constants inherited from Vines::Stanza

EMPTY, ROUTABLE_STANZAS

Instance Attribute Summary

Attributes inherited from Vines::Stanza

#stream

Instance Method Summary collapse

Methods inherited from Vines::Stanza

#broadcast, from_node, #initialize, #local?, #local_jid?, #method_missing, register, #route, #router, #send_unavailable, #storage, #to_pubsub_domain?, #unavailable, #validate_from, #validate_to

Constructor Details

This class inherits a constructor from Vines::Stanza

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vines::Stanza

Instance Method Details

#processObject



16
17
18
19
20
21
22
# File 'lib/vines/stanza/iq.rb', line 16

def process
  if self['id'] && VALID_TYPES.include?(self['type'])
    route_iq or raise StanzaErrors::FeatureNotImplemented.new(@node, 'cancel')
  else
    raise StanzaErrors::BadRequest.new(@node, 'modify')
  end
end

#to_resultObject



24
25
26
27
28
29
30
31
# File 'lib/vines/stanza/iq.rb', line 24

def to_result
  doc = Document.new
  doc.create_element('iq',
    'from' => validate_to || stream.domain,
    'id'   => self['id'],
    'to'   => stream.user.jid,
    'type' => 'result')
end