lib/vines/storage/couchdb.rb in vines-0.2.1 vs lib/vines/storage/couchdb.rb in vines-0.3.0
- old
+ new
@@ -21,11 +21,11 @@
[:host, :port, :database].each {|key| raise "Must provide #{key}" unless @config[key] }
@url = url(@config)
end
def find_user(jid)
- jid = JID.new(jid || '').bare.to_s
+ jid = JID.new(jid).bare.to_s
if jid.empty? then yield; return end
get("user:#{jid}") do |doc|
user = if doc && doc['type'] == 'User'
User.new(:jid => jid).tap do |user|
user.name, user.password = doc.values_at('name', 'password')
@@ -59,11 +59,11 @@
end
end
fiber :save_user
def find_vcard(jid)
- jid = JID.new(jid || '').bare.to_s
+ jid = JID.new(jid).bare.to_s
if jid.empty? then yield; return end
get("vcard:#{jid}") do |doc|
card = if doc && doc['type'] == 'Vcard'
Nokogiri::XML(doc['card']).root rescue nil
end
@@ -83,10 +83,10 @@
end
end
fiber :save_vcard
def find_fragment(jid, node)
- jid = JID.new(jid || '').bare.to_s
+ jid = JID.new(jid).bare.to_s
if jid.empty? then yield; return end
get(fragment_id(jid, node)) do |doc|
fragment = if doc && doc['type'] == 'Fragment'
Nokogiri::XML(doc['xml']).root rescue nil
end