Module: Mensa::Scope
Overview
scope -> filtered_scope -> ordered_scope -> selected_scope ->
Instance Method Summary collapse
-
#filtered_scope ⇒ Object
Returns the scope, but filtered.
-
#ordered_scope ⇒ Object
Returns the filtered_columns, but ordered, we always reorder, scope shouldn’t include ordering.
- #paged_scope ⇒ Object
- #pagy_details ⇒ Object
-
#selected_scope ⇒ Object
Return the ordered_scope, but with only the columns selected.
Instance Method Details
#filtered_scope ⇒ Object
Returns the scope, but filtered
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/tables/mensa/scope.rb', line 12 def filtered_scope return @filtered_scope if @filtered_scope @filtered_scope = scope # See https://github.com/textacular/textacular # This has problems - not all table fields are searched if params[:query].present? @filtered_scope = if Mensa.config.search == :fuzzy @filtered_scope.fuzzy_search(params[:query]) else @filtered_scope.basic_search(params[:query]) end end # Use inject active_filters.each do |filter| @filtered_scope = filter.filter_scope(@filtered_scope) end @filtered_scope end |
#ordered_scope ⇒ Object
Returns the filtered_columns, but ordered, we always reorder, scope shouldn’t include ordering
35 36 37 38 39 40 41 42 |
# File 'app/tables/mensa/scope.rb', line 35 def ordered_scope return @ordered_scope if @ordered_scope @ordered_scope = filtered_scope @ordered_scope = @ordered_scope.reorder(effective_order) @ordered_scope end |
#paged_scope ⇒ Object
54 55 56 57 |
# File 'app/tables/mensa/scope.rb', line 54 def paged_scope pagy_object @records end |
#pagy_details ⇒ Object
59 60 61 62 |
# File 'app/tables/mensa/scope.rb', line 59 def pagy_details pagy_object @pagy_details end |
#selected_scope ⇒ Object
Return the ordered_scope, but with only the columns selected
45 46 47 48 49 50 51 52 |
# File 'app/tables/mensa/scope.rb', line 45 def selected_scope return @selected_scope if @selected_scope @selected_scope = ordered_scope @selected_scope = @selected_scope.select([:id] + columns.filter_map(&:attribute)) @selected_scope end |