Class: Ddr::Index::QueryParams

Inherits:
Object
  • Object
show all
Defined in:
lib/ddr/index/query_params.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ QueryParams

Returns a new instance of QueryParams.



6
7
8
# File 'lib/ddr/index/query_params.rb', line 6

def initialize(query)
  @query = query
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



4
5
6
# File 'lib/ddr/index/query_params.rb', line 4

def query
  @query
end

Instance Method Details

#fieldsObject



27
28
29
# File 'lib/ddr/index/query_params.rb', line 27

def fields
  query.fields.join(",")
end

#filter_queriesObject



23
24
25
# File 'lib/ddr/index/query_params.rb', line 23

def filter_queries
  query.filter_clauses.map(&:to_s)
end

#paramsObject



10
11
12
13
14
15
16
17
# File 'lib/ddr/index/query_params.rb', line 10

def params
  { q:    q_param,
    fq:   filter_queries,
    fl:   fields,
    sort: sort,
    rows: rows,
  }.select { |k, v| v.present? }
end

#q_paramObject



19
20
21
# File 'lib/ddr/index/query_params.rb', line 19

def q_param
  query.q.to_s
end

#rowsObject



35
36
37
# File 'lib/ddr/index/query_params.rb', line 35

def rows
  query.rows
end

#sortObject



31
32
33
# File 'lib/ddr/index/query_params.rb', line 31

def sort
  query.sort.join(",")
end