Sha256: cf0aa3f94352125d65db72f55a031ebfd87ed31dff73fbff288c8eddfc3668d9

Contents?: true

Size: 1.05 KB

Versions: 13

Compression:

Stored size: 1.05 KB

Contents

module Blather
class Stanza
class Presence

  class Subscription < Presence
    register :subscription, :subscription

    def self.new(to = nil, type = nil)
      node = super()
      node.to = to
      node.type = type
      node
    end

    def inherit(node)
      inherit_attrs node.attributes
      self
    end

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

    ##
    # Create an approve stanza
    def approve!
      self.type = :subscribed
      reply_if_needed!
    end

    ##
    # Create a refuse stanza
    def refuse!
      self.type = :unsubscribed
      reply_if_needed!
    end

    ##
    # Create an unsubscribe stanza
    def unsubscribe!
      self.type = :unsubscribe
      reply_if_needed!
    end

    ##
    # Create a cancel stanza
    def cancel!
      self.type = :unsubscribed
      reply_if_needed!
    end

    ##
    # Create a request stanza
    def request!
      self.type = :subscribe
      reply_if_needed!
    end

    def request?
      self.type == :subscribe
    end

  end #Subscription

end #Presence
end #Stanza
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sprsquish-blather-0.4.0 lib/blather/stanza/presence/subscription.rb
sprsquish-blather-0.4.1 lib/blather/stanza/presence/subscription.rb
sprsquish-blather-0.4.2 lib/blather/stanza/presence/subscription.rb
sprsquish-blather-0.4.3 lib/blather/stanza/presence/subscription.rb
sprsquish-blather-0.4.4 lib/blather/stanza/presence/subscription.rb
blather-0.4.7 lib/blather/stanza/presence/subscription.rb
blather-0.4.6 lib/blather/stanza/presence/subscription.rb
blather-0.4.5 lib/blather/stanza/presence/subscription.rb
blather-0.4.4 lib/blather/stanza/presence/subscription.rb
blather-0.4.3 lib/blather/stanza/presence/subscription.rb
blather-0.4.2 lib/blather/stanza/presence/subscription.rb
blather-0.4.1 lib/blather/stanza/presence/subscription.rb
blather-0.4.0 lib/blather/stanza/presence/subscription.rb