Class: Decidim::ResourceLocatorPresenter
- Inherits:
-
Rectify::Presenter
- Object
- Rectify::Presenter
- Decidim::ResourceLocatorPresenter
- Defined in:
- app/presenters/decidim/resource_locator_presenter.rb
Overview
A presenter to get the url or path from a resource.
Instance Method Summary collapse
-
#initialize(resource) ⇒ ResourceLocatorPresenter
constructor
A new instance of ResourceLocatorPresenter.
-
#path(options = {}) ⇒ Object
Builds the path to a resource.
-
#url(options = {}) ⇒ Object
Builds the url to a resource.
Constructor Details
#initialize(resource) ⇒ ResourceLocatorPresenter
Returns a new instance of ResourceLocatorPresenter.
6 7 8 |
# File 'app/presenters/decidim/resource_locator_presenter.rb', line 6 def initialize(resource) @resource = resource end |
Instance Method Details
#path(options = {}) ⇒ Object
Builds the path to a resource. Useful when linking to a resource from another engine.
options - An optional hash of options to pass to the Rails router
Returns a String.
16 17 18 |
# File 'app/presenters/decidim/resource_locator_presenter.rb', line 16 def path( = {}) _route(@resource, "path", ) end |
#url(options = {}) ⇒ Object
Builds the url to a resource. Useful when linking to a resource from another engine.
options - An optional hash of options to pass to the Rails router
Returns a String.
26 27 28 |
# File 'app/presenters/decidim/resource_locator_presenter.rb', line 26 def url( = {}) _route(@resource, "url", .merge(host: @resource.organization.host)) end |