Class: Workarea::FindTaxonomySlug
- Inherits:
-
Object
- Object
- Workarea::FindTaxonomySlug
- Defined in:
- app/queries/workarea/find_taxonomy_slug.rb
Instance Method Summary collapse
-
#initialize(navigable, taxon = nil) ⇒ FindTaxonomySlug
constructor
A new instance of FindTaxonomySlug.
- #slug ⇒ Object
Constructor Details
#initialize(navigable, taxon = nil) ⇒ FindTaxonomySlug
Returns a new instance of FindTaxonomySlug.
3 4 5 6 |
# File 'app/queries/workarea/find_taxonomy_slug.rb', line 3 def initialize(navigable, taxon = nil) @navigable = navigable @taxon = taxon || navigable.taxon end |
Instance Method Details
#slug ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/queries/workarea/find_taxonomy_slug.rb', line 8 def slug return unless @taxon.present? taxons = @taxon.ancestors_and_self taxons.shift # remove the first, root taxon slug = taxons .map { |t| t.navigable.try(:name) || t.name } .compact .map { |name| name.delete("'").parameterize } .join('-') FindUniqueSlug.new(@navigable, slug).slug end |