Class: Workarea::TaxonomySitemap

Inherits:
Object
  • Object
show all
Includes:
Search::Pagination
Defined in:
app/queries/workarea/taxonomy_sitemap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Search::Pagination

#each_by, #from, #page, #per_page, #size

Constructor Details

#initialize(params = {}) ⇒ TaxonomySitemap

Returns a new instance of TaxonomySitemap.



9
10
11
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 9

def initialize(params = {})
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 5

def params
  @params
end

Instance Method Details

#cache_keyObject



30
31
32
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 30

def cache_key
  ['taxonomy_sitemap', I18n.locale, page, per_page].join('/')
end

#resultsObject



26
27
28
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 26

def results
  @results ||= taxons.select(&:active?)
end

#second_page?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 13

def second_page?
  page == 2
end

#taxonsObject



17
18
19
20
21
22
23
24
# File 'app/queries/workarea/taxonomy_sitemap.rb', line 17

def taxons
  @taxons ||=
    Navigation::Taxon
      .page(page)
      .per(per_page)
      .any_of({ :url.ne => nil }, { :navigable_id.ne => nil })
      .reorder(:parent_ids.asc)
end