Sha256: 7db92321c31285e1de2fa913813c30e4fc65751ebbd2b8572842e013e3b9390c

Contents?: true

Size: 637 Bytes

Versions: 5

Compression:

Stored size: 637 Bytes

Contents

class PageDecorator < ApplicationDecorator
  delegate_all

  def options_for_parents
    Page.flat_tree.map do |p|
      ["#{'-' * p.depth} #{p.description}".strip, p.id]
    end
  end

  def path(locale: I18n.locale, options: {})
    return h.send(route, options) if route.present?

    slugs = []

    parents.each do |p|
      if p.route.present?
        slugs << h.send(p.route, options)
        return slugs.reverse.join('/')
      else
        slugs << p.seo(locale).slug
      end
    end

    str = ''
    str << "/#{locale}" if Udongo.config.routes.prefix_with_locale?
    str << "/#{slugs.reverse.join('/')}"
    str
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
udongo-2.0.4 app/decorators/page_decorator.rb
udongo-2.0.3 app/decorators/page_decorator.rb
udongo-2.0.2 app/decorators/page_decorator.rb
udongo-2.0.1 app/decorators/page_decorator.rb
udongo-2.0.0 app/decorators/page_decorator.rb