Class: SiteSearch::Query::Result
- Inherits:
-
Data
- Object
- Data
- SiteSearch::Query::Result
- Defined in:
- app/services/site_search/query.rb
Overview
A whole search response: what was asked, what came back, and where it sits.
Instance Attribute Summary collapse
-
#degraded ⇒ Object
readonly
Returns the value of attribute degraded.
-
#pagination ⇒ Object
readonly
Returns the value of attribute pagination.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#as_json ⇒ Hash
totalandhas_moresit alongsidepaginationbecause the modal heading reads a single number and the scroll guard reads a single boolean. -
#initialize(query: nil, type: DEFAULT_TYPE, results: [], pagination: Pagination.new, degraded: false) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(query: nil, type: DEFAULT_TYPE, results: [], pagination: Pagination.new, degraded: false) ⇒ Result
Returns a new instance of Result.
48 49 50 51 |
# File 'app/services/site_search/query.rb', line 48 def initialize(query: nil, type: DEFAULT_TYPE, results: [], pagination: Pagination.new, degraded: false) super end |
Instance Attribute Details
#degraded ⇒ Object (readonly)
Returns the value of attribute degraded
42 43 44 |
# File 'app/services/site_search/query.rb', line 42 def degraded @degraded end |
#pagination ⇒ Object (readonly)
Returns the value of attribute pagination
42 43 44 |
# File 'app/services/site_search/query.rb', line 42 def pagination @pagination end |
#query ⇒ Object (readonly)
Returns the value of attribute query
42 43 44 |
# File 'app/services/site_search/query.rb', line 42 def query @query end |
#results ⇒ Object (readonly)
Returns the value of attribute results
42 43 44 |
# File 'app/services/site_search/query.rb', line 42 def results @results end |
#type ⇒ Object (readonly)
Returns the value of attribute type
42 43 44 |
# File 'app/services/site_search/query.rb', line 42 def type @type end |
Instance Method Details
#as_json ⇒ Hash
total and has_more sit alongside pagination because the modal
heading reads a single number and the scroll guard reads a single boolean.
57 58 59 60 |
# File 'app/services/site_search/query.rb', line 57 def as_json(*) { query:, type:, total: pagination.count, has_more: pagination.next_page.present?, degraded:, pagination: pagination.as_json, results: results.map(&:as_json) } end |