Class: Ansr::Blacklight::Relation
- Inherits:
-
Relation
- Object
- Relation
- Ansr::Blacklight::Relation
- Includes:
- SolrProjectionMethods
- Defined in:
- lib/ansr_blacklight/relation.rb
Instance Method Summary collapse
- #build_arel ⇒ Object
- #count ⇒ Object
-
#docs_from(response) ⇒ Object
overrides for query response handling.
- #filters_from(response) ⇒ Object
- #group_by(key = self.group_values.first) ⇒ Object
- #grouped? ⇒ Boolean
- #limit_value ⇒ Object
-
#max_pages ⇒ Object
overrides for weird Blacklight expectations.
Instance Method Details
#build_arel ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ansr_blacklight/relation.rb', line 38 def build_arel arel = super solr_props = {} solr_props[:defType] = defType_value if defType_value solr_props[:wt] = wt_value if wt_value unless solr_props.empty? prop_node = Ansr::Arel::Nodes::ProjectionTraits.new arel.grouping(arel.projections), solr_props arel.projections = [prop_node] end arel end |
#count ⇒ Object
21 22 23 |
# File 'lib/ansr_blacklight/relation.rb', line 21 def count response.total end |
#docs_from(response) ⇒ Object
overrides for query response handling
13 14 15 |
# File 'lib/ansr_blacklight/relation.rb', line 13 def docs_from(response) response.docs end |
#filters_from(response) ⇒ Object
17 18 19 |
# File 'lib/ansr_blacklight/relation.rb', line 17 def filters_from(response) response.facets end |
#group_by(key = self.group_values.first) ⇒ Object
54 55 56 57 |
# File 'lib/ansr_blacklight/relation.rb', line 54 def group_by(key=self.group_values.first) loaded response.group(key, model) end |
#grouped? ⇒ Boolean
50 51 52 |
# File 'lib/ansr_blacklight/relation.rb', line 50 def grouped? loaded? ? response.grouped? : !group_values.blank? end |
#limit_value ⇒ Object
34 35 36 |
# File 'lib/ansr_blacklight/relation.rb', line 34 def limit_value (super || default_limit_value) + 1 end |
#max_pages ⇒ Object
overrides for weird Blacklight expectations
26 27 28 29 30 31 32 |
# File 'lib/ansr_blacklight/relation.rb', line 26 def max_pages if Kaminari.config.respond_to? :max_pages nil else super end end |