Sha256: 919a6a109752b48ea0a6957568c8b00b93f72d2641533712850ee32756950ac6

Contents?: true

Size: 1.04 KB

Versions: 23

Compression:

Stored size: 1.04 KB

Contents

module Blather
class Stanza
class MUC

  module MUCUserBase
    MUC_USER_NAMESPACE = "http://jabber.org/protocol/muc#user"

    def self.included(klass)
      klass.extend ClassMethods
    end

    module ClassMethods
      def new(*args)
        super.tap { |e| e.muc_user }
      end
    end

    def inherit(node)
      muc_user.remove
      super
      self
    end

    def password
      find_password_node && password_node.content
    end

    def password=(var)
      password_node.content = var
    end

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

    def password_node
      unless pw = find_password_node
        muc_user << (pw = XMPPNode.new('password', self.document))
      end
      pw
    end

    def find_password_node
      muc_user.find_first 'ns:password', :ns => MUC_USER_NAMESPACE
    end
  end # MUCUserBase

end # MUC
end # Stanza
end # Blather

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
blather-2.0.0 lib/blather/stanza/muc/muc_user_base.rb
blather-1.2.0 lib/blather/stanza/muc/muc_user_base.rb
blather-1.1.4 lib/blather/stanza/muc/muc_user_base.rb
blather-1.1.3 lib/blather/stanza/muc/muc_user_base.rb
blather-1.1.2 lib/blather/stanza/muc/muc_user_base.rb
blather-1.1.1 lib/blather/stanza/muc/muc_user_base.rb
blather-1.1.0 lib/blather/stanza/muc/muc_user_base.rb
blather-1.0.0 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.8 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.7 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.6 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.5 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.4 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.3 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.2 lib/blather/stanza/muc/muc_user_base.rb
tp-blather-0.8.5 lib/blather/stanza/muc/muc_user_base.rb
tp-blather-0.8.4 lib/blather/stanza/muc/muc_user_base.rb
tp-blather-0.8.3 lib/blather/stanza/muc/muc_user_base.rb
tp-blather-0.8.2 lib/blather/stanza/muc/muc_user_base.rb
blather-0.8.1 lib/blather/stanza/muc/muc_user_base.rb