Module: Facet::Collection

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/facet/concerns/collection.rb

Instance Method Summary collapse

Instance Method Details

#collectionObject



17
18
19
# File 'lib/facet/concerns/collection.rb', line 17

def collection
  (source? ? source.public_send(self_scope) : record_class).public_send(record_scope)
end

#filtered_collectionObject (private)



39
40
41
42
43
# File 'lib/facet/concerns/collection.rb', line 39

def filtered_collection
  return collection unless filtered?

  collection.public_send(filter_by)
end

#outputObject Also known as: to_ary



21
22
23
24
25
# File 'lib/facet/concerns/collection.rb', line 21

def output
  return sorted_filtered_collection unless current_page.present? && current_page >= 0

  sorted_filtered_collection.paginate(page: current_page)
end

#sorted_filtered_collectionObject (private)



33
34
35
36
37
# File 'lib/facet/concerns/collection.rb', line 33

def sorted_filtered_collection
  return filtered_collection unless sorted?

  filtered_collection.public_send(sort_by)
end