Class: Clerq::Services::QueryNode
- Defined in:
- lib/clerq/services/query_node.rb
Overview
Provides repository nodes assembly Usage
QueryAssembly.(asse:, query:)
QueryAssembly.(query_string)
Rules for root node:
when query not passed, it return the whole hierarchy
when nodes not found, it returns empty root node with meta[:query]
when query returns one single node, it returns this node
when query returns mare than one nodes, then
* it creates empty root node with meta[:query]
* and places found nodes to the root
Instance Method Summary collapse
Methods inherited from Service
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/clerq/services/query_node.rb', line 25 def call proc = prepare_query unless @query.empty? arry = @assembly.select{|node| proc.call(node) } return arry.first.orphan! if arry.size == 1 node = Node.new(title: Clerq.title, meta: {query: @query}) arry.each{|n| node << n.orphan!} node end |