Module: Katalyst::Tables::Collection::Core
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/katalyst/tables/collection/core.rb
Overview
:nodoc:
Instance Method Summary collapse
- #apply(items) ⇒ Object
- #filter ⇒ Object
-
#filtered? ⇒ Boolean
Collections are filtered when any parameters have changed from their defaults.
- #filters ⇒ Object
- #initialize(**options) ⇒ Object
- #model ⇒ Object
-
#searchable? ⇒ Boolean
Collections that do not include Query are never searchable.
-
#sortable? ⇒ Boolean
Collections that do not include Sorting are never sortable.
Methods included from HasParams
Instance Method Details
#apply(items) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 89 def apply(items) @unscoped_items = @items = items reducers.build do |_| filter self end.call(self) self end |
#filter ⇒ Object
98 99 100 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 98 def filter # no-op by default end |
#filtered? ⇒ Boolean
Collections are filtered when any parameters have changed from their defaults.
75 76 77 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 75 def filtered? filters.any? end |
#filters ⇒ Object
102 103 104 105 106 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 102 def filters changes .select { |k, _| self.class._default_attributes[k].type.filterable? } .transform_values(&:second) end |
#initialize(**options) ⇒ Object
68 69 70 71 72 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 68 def initialize(**) super clear_changes_information end |
#model ⇒ Object
108 109 110 111 112 113 114 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 108 def model if items < ActiveRecord::Base items else items.model end end |
#searchable? ⇒ Boolean
Collections that do not include Query are never searchable.
85 86 87 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 85 def searchable? false end |
#sortable? ⇒ Boolean
Collections that do not include Sorting are never sortable.
80 81 82 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 80 def sortable? false end |