Class: JabberAdmin::Commands::SetVcard
- Inherits:
-
Object
- Object
- JabberAdmin::Commands::SetVcard
- Defined in:
- lib/jabber_admin/commands/set_vcard.rb
Overview
Set contents in a vCard.
Examples:
JabberAdmin.set_vcard!(
user: '[email protected]',
'org.orgunit[]' => %w[Marketing Production],
fn: 'Max Mustermann',
'n.given': 'Max',
'n.family' => 'Mustermann'
)
# => {"org.orgunit[]"=>["Marketing", "Production"],
# "n.family"=>"Mustermann",
# :fn=>"Max Mustermann",
# :"n.given"=>"Max"}
Class Method Summary collapse
-
.call(callable, args = {}, user:, **sym_args) ⇒ Hash
Pass the correct data to the given callable.
Class Method Details
.call(callable, args = {}, user:, **sym_args) ⇒ Hash
Pass the correct data to the given callable.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jabber_admin/commands/set_vcard.rb', line 34 def self.call(callable, args = {}, user:, **sym_args) args = args.merge(sym_args) uid, host = user.split('@') set = proc do |key, val| parts = key.to_s.upcase.split('.') body = { name: parts.shift, content: val } meth = 'set_vcard' unless parts.empty? body[:subname] = parts.shift meth = 'set_vcard2' if body[:subname].end_with? '[]' meth += '_multi' body[:subname].delete_suffix!('[]') body[:contents] = body.delete(:content) end end callable.call(meth, user: uid, host: host, **body) end args.each { |key, val| set[key, val] } args end |