Module: Katalyst::Tables::Collection::Core
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Attributes, ActiveModel::Dirty, ActiveModel::Model, ActiveSupport::Configurable, HasParams, Reducers
- 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
75 76 77 78 79 80 81 82 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 75 def apply(items) @unscoped_items = @items = items reducers.build do |_| filter self end.call(self) self end |
#filter ⇒ Object
84 85 86 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 84 def filter # no-op by default end |
#filtered? ⇒ Boolean
Collections are filtered when any parameters have changed from their defaults.
61 62 63 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 61 def filtered? filters.any? end |
#filters ⇒ Object
88 89 90 91 92 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 88 def filters changes .select { |k, _| self.class._default_attributes[k].type.filterable? } .transform_values(&:second) end |
#initialize(**options) ⇒ Object
54 55 56 57 58 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 54 def initialize(**) super clear_changes_information end |
#model ⇒ Object
94 95 96 97 98 99 100 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 94 def model if items < ActiveRecord::Base items else items.model end end |
#searchable? ⇒ Boolean
Collections that do not include Query are never searchable.
71 72 73 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 71 def searchable? false end |
#sortable? ⇒ Boolean
Collections that do not include Sorting are never sortable.
66 67 68 |
# File 'app/models/concerns/katalyst/tables/collection/core.rb', line 66 def sortable? false end |