Class: Decidim::ResourceLocatorPresenter
- Inherits:
-
Object
- Object
- Decidim::ResourceLocatorPresenter
- Defined in:
- decidim-core/app/presenters/decidim/resource_locator_presenter.rb
Overview
A presenter to get the url or path from a resource.
Instance Method Summary collapse
-
#index(options = {}) ⇒ Object
Builds the index path to the associated collection of resources.
-
#initialize(resource) ⇒ ResourceLocatorPresenter
constructor
A new instance of ResourceLocatorPresenter.
-
#path(options = {}) ⇒ Object
Builds the path to the resource.
-
#url(options = {}) ⇒ Object
Builds the url to the resource.
Constructor Details
#initialize(resource) ⇒ ResourceLocatorPresenter
Returns a new instance of ResourceLocatorPresenter.
6 7 8 |
# File 'decidim-core/app/presenters/decidim/resource_locator_presenter.rb', line 6 def initialize(resource) @resource = resource end |
Instance Method Details
#index(options = {}) ⇒ Object
Builds the index path to the associated collection of resources.
options - An optional hash of options to pass to the Rails router
Returns a String.
35 36 37 |
# File 'decidim-core/app/presenters/decidim/resource_locator_presenter.rb', line 35 def index( = {}) collection_route("path", ) end |
#path(options = {}) ⇒ Object
Builds the path to the 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 'decidim-core/app/presenters/decidim/resource_locator_presenter.rb', line 16 def path( = {}) member_route("path", ) end |
#url(options = {}) ⇒ Object
Builds the url to the 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 'decidim-core/app/presenters/decidim/resource_locator_presenter.rb', line 26 def url( = {}) member_route("url", .merge(host: @resource.organization.host)) end |