Class: VcardCache

Inherits:
Jabber::Vcard::Helper show all
Defined in:
lib/vendor/xmpp4r/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Jabber::Vcard::Helper

get, #set, set

Constructor Details

#initialize(stream) ⇒ VcardCache

Returns a new instance of VcardCache.



41
42
43
44
# File 'lib/vendor/xmpp4r/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 41

def initialize(stream)
  super
  @vcards = {}
end

Instance Attribute Details

#vcardsObject (readonly)

Returns the value of attribute vcards.



39
40
41
# File 'lib/vendor/xmpp4r/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 39

def vcards
  @vcards
end

Instance Method Details

#get(jid) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vendor/xmpp4r/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 46

def get(jid)
  unless @vcards[jid]
    begin
      @vcards[jid] = super
    rescue Jabber::ServerError
      @vcards[jid] = :error
    end
  end

  @vcards[jid]
end

#get_until(jid, timeout = 10) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/vendor/xmpp4r/data/doc/xmpp4r/examples/advanced/pep-aggregator/pep-aggregator.rb', line 58

def get_until(jid, timeout=10)
  begin
    Timeout::timeout(timeout) {
      get(jid)
    }
  rescue Timeout::Error
    @vcards[jid] = :timeout
  end

  @vcards[jid]
end