Class: SirTrevorRails::Blocks::SearchResultsBlock
- Inherits:
-
SirTrevorRails::Block
- Object
- OpenStruct
- SirTrevorRails::Block
- SirTrevorRails::Blocks::SearchResultsBlock
- 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
Constant Summary
Constants inherited from SirTrevorRails::Block
SirTrevorRails::Block::DEFAULT_FORMAT
Instance Attribute Summary
Attributes inherited from SirTrevorRails::Block
Instance Method Summary collapse
Methods included from Displayable
#item_ids, #items, #ordered_items
Methods inherited from SirTrevorRails::Block
#as_json, block_class, block_class!, custom_block_types, #format, from_hash, #initialize, #to_partial_path, type_klass
Constructor Details
This class inherits a constructor from SirTrevorRails::Block
Instance Method Details
#query_params ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 10 def query_params if search search.query_params else {} end end |
#search ⇒ Object
18 19 20 |
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 18 def search searches.first end |
#searches ⇒ Object
22 23 24 |
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 22 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
26 27 28 |
# File 'app/models/sir_trevor_rails/blocks/search_results_block.rb', line 26 def searches? !searches.empty? end |