Revision ee2c32c3
Added by Marc Dequènes about 13 years ago
- ID ee2c32c3f26e0d62c2a169beb342a54a15a94e79
lib/cyborghood/cyborg/botnet/interface.rb | ||
---|---|---|
end
|
||
|
||
def search_among_children(request, lookup_node)
|
||
node_names_list = []
|
||
criterias = request.args.first
|
||
return {} unless criterias.is_a? Hash
|
||
|
||
node_names_list = {}
|
||
|
||
lookup_node.__send__(:visible_nodes).each do |match, node|
|
||
if match.is_a? String
|
||
... | ... | |
result = node.__send__(:request, request.session)
|
||
next unless result.respond_to? :to_hash
|
||
|
||
if hash_match_criterias(result.to_hash, request.args.first)
|
||
node_names_list << child_node_name
|
||
child_node_attrs = result.to_hash
|
||
|
||
if hash_match_criterias(child_node_attrs, criterias)
|
||
node_names_list[child_node_name] = child_node_attrs
|
||
end
|
||
end
|
||
end
|
||
... | ... | |
|
||
def search_in_list(request, lookup_node, list)
|
||
criterias = request.args.first
|
||
return [] unless criterias.is_a? Hash
|
||
return {} unless criterias.is_a? Hash
|
||
|
||
if list.is_a? Proc
|
||
list = list.call(criterias)
|
||
# if result is an array, then a final list of names is given, return it
|
||
return list if list.is_a? Array
|
||
# else it must be a Hash which needs to be filtered
|
||
data = list.call(criterias)
|
||
|
||
return data[:list] unless data[:post_filter]
|
||
end
|
||
|
||
node_names_list = []
|
||
node_names_list = {}
|
||
|
||
data[:list].each do |element_name, element|
|
||
element_attrs = element.to_hash
|
||
|
||
list.each do |element_name, element|
|
||
if hash_match_criterias(element.to_hash, criterias)
|
||
node_names_list << element_name
|
||
if hash_match_criterias(element_attrs, criterias)
|
||
node_names_list[element_name] = element_attrs
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
[evol] Botnet/Interface: '/?' search now return a Hash in order to get the object name easily for further manipulations, updated Librarian accordingly