Class: Hyrax::ContextualPath

Inherits:
Object
  • Object
show all
Includes:
ActionDispatch::Routing::PolymorphicRoutes
Defined in:
app/services/hyrax/contextual_path.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(presenter, parent_presenter) ⇒ ContextualPath

Returns a new instance of ContextualPath.


7
8
9
10
# File 'app/services/hyrax/contextual_path.rb', line 7

def initialize(presenter, parent_presenter)
  @presenter = presenter
  @parent_presenter = parent_presenter
end

Instance Attribute Details

#parent_presenterObject (readonly)

Returns the value of attribute parent_presenter


6
7
8
# File 'app/services/hyrax/contextual_path.rb', line 6

def parent_presenter
  @parent_presenter
end

#presenterObject (readonly)

Returns the value of attribute presenter


6
7
8
# File 'app/services/hyrax/contextual_path.rb', line 6

def presenter
  @presenter
end

Instance Method Details

#showObject


12
13
14
15
16
17
18
19
20
# File 'app/services/hyrax/contextual_path.rb', line 12

def show
  if parent_presenter
    polymorphic_path([:hyrax, :parent, presenter.model_name.singular.to_sym],
                     parent_id: parent_presenter.id,
                     id: presenter.id)
  else
    polymorphic_path([presenter])
  end
end