Project

General

Profile

« Previous | Next » 

Revision 7bfcd98b

Added by Marc Dequènes about 13 years ago

  • ID 7bfcd98b929705cc5c65b729a60f022827a66bfe

[evol] Librarian API work §3

View differences:

lib/cyborghood-librarian/interface/0_base.rb
node 'Records' do
node ['Persons', 'DnsDomains'] do
object_list = Proc.new{|obj_name| bot.services.records.send(node_name.underscore, obj_name) }
object_list = Proc.new do |*args|
obj_name, options = args
options ||= {}
bot.services.records.send(node_name.underscore, obj_name, options)
end
on_request do |request|
request.reply.results = object_list.call
end
attr_search_node do |criterias|
object_list.call(:search, :criterias => criterias, :format => :data_hash)
end
node object_list do
on_request do |request|
prepare_value = Proc.new do |v|
if v.is_a? Array
v.collect!{|v2| prepare_value.call(v2) }
elsif v.is_a? ActiveLdap::DistinguishedName
v.to_s
else
v
end
end
obj_attrs = object_list.call(node_name).attributes
obj_attrs.delete('objectClass')
obj_attrs.each do |k, v|
obj_attrs[k] = prepare_value.call(v)
end
request.reply.results = obj_attrs
request.reply.results = object_list.call(node_name, :format => :data_hash)
end
end
end

Also available in: Unified diff