Sha256: a87361e6acb3f37cde3ba158d1024a2ad885af7c86cfd3d60e810e8ac0aa7646

Contents?: true

Size: 985 Bytes

Versions: 13

Compression:

Stored size: 985 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  # This module exposes a helper method to access the resource that is linked
  # to the current item, via the `included_in` parameter, and its associated
  # resource locator.
  module LinkedResourceReference
    extend ActiveSupport::Concern

    included do
      helper_method :linked_resource, :located_linked_resource
    end

    private

    def linked_resource
      @linked_resource ||= (GlobalID::Locator.locate(params[:included_in]) if params[:included_in])
    end

    def located_linked_resource
      @located_linked_resource ||= if linked_resource.is_a?(Decidim::Budgets::Project)
                                     Decidim::ResourceLocatorPresenter.new([linked_resource.budget, linked_resource])
                                   else
                                     Decidim::ResourceLocatorPresenter.new(linked_resource)
                                   end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.4 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.29.0 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.3 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.29.0.rc4 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.29.0.rc3 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.29.0.rc2 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.29.0.rc1 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.2 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.1 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.0 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.0.rc5 app/controllers/concerns/decidim/linked_resource_reference.rb
decidim-core-0.28.0.rc4 app/controllers/concerns/decidim/linked_resource_reference.rb