Class: SirTrevorRails::Blocks::SearchResultsBlock

Inherits:
SirTrevorRails::Block
  • Object
show all
Includes:
Displayable
Defined in:
app/models/sir_trevor_rails/blocks/search_results_block.rb

Overview

Embed search results (from a browse category) into the page

Instance Method Summary collapse

Methods included from Displayable

#item_ids, #items, #ordered_items

Instance Method Details

#query_paramsObject



8
9
10
11
12
13
14
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 8

def query_params
  if search
    search.query_params
  else
    {}
  end
end

#searchObject



16
17
18
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 16

def search
  searches.first
end

#searchesObject



20
21
22
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 20

def searches
  @searches ||= parent.exhibit.searches.published.where(slug: item_ids).sort { |a, b| ordered_items.index(a.id) <=> ordered_items.index(b.id) }
end

#searches?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 24

def searches?
  !searches.empty?
end