Sha256: 5a8b58258e78454aec3f35990aeef0559d5ecb0f49fbd99fef1bdde219c6482c

Contents?: true

Size: 888 Bytes

Versions: 24

Compression:

Stored size: 888 Bytes

Contents

# encoding: utf-8

require 'ruby_jid'

module Punchblock
  ##
  # A rayo Ref message. This provides the command ID in response to execution of a command.
  #
  class Ref < RayoNode
    register :ref, :core

    # @return [String] the command URI
    attribute :uri
    def uri=(other)
      super URI(other)
    end

    def scheme
      uri.scheme
    end

    def call_id
      case scheme
      when 'xmpp'
        RubyJID.new(uri.opaque).node
      when nil
        uri.path
      else
        uri.opaque
      end
    end

    def domain
      case scheme
      when 'xmpp'
        RubyJID.new(uri.opaque).domain
      end
    end

    def component_id
      case scheme
      when 'xmpp'
        RubyJID.new(uri.opaque).resource
      else
        call_id
      end
    end

    def rayo_attributes
      {}.tap do |atts|
        atts[:uri] = uri if uri
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
punchblock-2.7.5 lib/punchblock/ref.rb
punchblock-2.7.3 lib/punchblock/ref.rb
punchblock-2.7.2 lib/punchblock/ref.rb
punchblock-2.7.1 lib/punchblock/ref.rb
punchblock-2.7.0 lib/punchblock/ref.rb
punchblock-2.6.0 lib/punchblock/ref.rb
punchblock-2.5.3 lib/punchblock/ref.rb
punchblock-2.5.2 lib/punchblock/ref.rb
punchblock-2.5.1 lib/punchblock/ref.rb
punchblock-2.5.0 lib/punchblock/ref.rb
punchblock-2.4.2 lib/punchblock/ref.rb
punchblock-2.4.0 lib/punchblock/ref.rb
punchblock-2.3.1 lib/punchblock/ref.rb
punchblock-2.3.0 lib/punchblock/ref.rb
punchblock-2.2.2 lib/punchblock/ref.rb
punchblock-2.2.1 lib/punchblock/ref.rb
punchblock-2.2.0 lib/punchblock/ref.rb
punchblock-2.1.1 lib/punchblock/ref.rb
punchblock-2.1.0 lib/punchblock/ref.rb
punchblock-2.0.2 lib/punchblock/ref.rb