lib/ddr/index/query.rb in ddr-models-2.4.0.rc5 vs lib/ddr/index/query.rb in ddr-models-2.4.0.rc6

- old
+ new

@@ -13,10 +13,17 @@ attribute :rows, Integer delegate [:count, :docs, :pids, :each_pid, :all] => :result delegate :params => :query_params + def initialize(**args, &block) + super(**args) + if block_given? + build(&block) + end + end + def inspect "#<#{self.class.name} q=#{q.inspect}, filters=#{filters.inspect}," \ " sort=#{sort.inspect}, rows=#{rows.inspect}, fields=#{fields.inspect}>" end @@ -36,9 +43,14 @@ filters.map(&:clauses).flatten end def query_params QueryParams.new(self) + end + + def build(&block) + QueryBuilder.new(self, &block) + self end end end