Module: Blather::Stanza::Presence::Subscription::InstanceMethods

Included in:
Blather::Stanza::Presence::Subscription
Defined in:
lib/blather/stanza/presence/subscription.rb

Instance Method Summary collapse

Instance Method Details

#approve!self

Transform the stanza into an approve stanza makes approving requests simple

Examples:

approve an incoming request

subscription(:request?) { |s| write_to_stream s.approve! }

Returns:

  • (self)


43
44
45
46
# File 'lib/blather/stanza/presence/subscription.rb', line 43

def approve!
  self.type = :subscribed
  reply_if_needed!
end

#cancel!self

Transform the stanza into a cancel stanza makes canceling simple

Returns:

  • (self)


72
73
74
75
# File 'lib/blather/stanza/presence/subscription.rb', line 72

def cancel!
  self.type = :unsubscribed
  reply_if_needed!
end

#refuse!self

Transform the stanza into a refuse stanza makes refusing requests simple

Examples:

refuse an incoming request

subscription(:request?) { |s| write_to_stream s.refuse! }

Returns:

  • (self)


54
55
56
57
# File 'lib/blather/stanza/presence/subscription.rb', line 54

def refuse!
  self.type = :unsubscribed
  reply_if_needed!
end

#request!self

Transform the stanza into a request stanza makes requests simple

Returns:

  • (self)


81
82
83
84
# File 'lib/blather/stanza/presence/subscription.rb', line 81

def request!
  self.type = :subscribe
  reply_if_needed!
end

#request?true, false

Check if the stanza is a request

Returns:

  • (true, false)


89
90
91
# File 'lib/blather/stanza/presence/subscription.rb', line 89

def request?
  self.type == :subscribe
end

#to=(to) ⇒ Object

Set the to value on the stanza

Parameters:



33
34
35
# File 'lib/blather/stanza/presence/subscription.rb', line 33

def to=(to)
  super JID.new(to).stripped
end

#unsubscribe!self

Transform the stanza into an unsubscribe stanza makes unsubscribing simple

Returns:

  • (self)


63
64
65
66
# File 'lib/blather/stanza/presence/subscription.rb', line 63

def unsubscribe!
  self.type = :unsubscribe
  reply_if_needed!
end