Sha256: 75290de41641105ad3ebbe3a3f8d353ededbfd76e4b48c272766b54d7fe51367

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

module Blather
class Stanza
class PubSub

  class Retract < PubSub
    register :pubsub_retract, :retract, self.registered_ns

    include Enumerable
    alias_method :find, :xpath

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

    def node
      retract[:node]
    end

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

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

    def retractions=(retractions = [])
      [retractions].flatten.each { |id| self.retract << PubSubItem.new(id, nil, self.document) }
    end

    def retractions
      retract.find('ns:item', :ns => self.class.registered_ns).map { |i| i[:id] }
    end

    def each(&block)
      retractions.each &block
    end

    def size
      retractions.size
    end
  end #Retract

end #PubSub
end #Stanza
end #Blather

Version data entries

13 entries across 13 versions & 2 rubygems

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