Sha256: da3f2d18ba2d095b88596d35a6ec61eb5b8cdfac1d8db5d7bc92a7230a14af3c

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module PublishMyData
  module ResourceRendering
    extend ActiveSupport::Concern

    included do

      private

      def render_resource(resource)
        respond_with(resource) do |format|
          format.html do
            resource.eager_load!

            logger.debug(locals_for_resource(resource))
            render template: template_for_resource(resource), locals: locals_for_resource(resource)
          end
        end
      end

      def template_for_resource(resource)
        {
          Dataset       => 'publish_my_data/datasets/show',
          Ontology      => 'publish_my_data/ontologies/show',
          ConceptScheme => 'publish_my_data/concept_schemes/show',
          OntologyClass => 'publish_my_data/classes/show',
          Property      => 'publish_my_data/properties/show',
          Concept       => 'publish_my_data/concepts/show',
          Resource      => 'publish_my_data/resources/show',
          ThirdParty::Ontology =>       'publish_my_data/ontologies/show',
          ThirdParty::ConceptScheme =>  'publish_my_data/concept_schemes/show'
        }[resource.class]
      end

      def locals_for_resource(resource)
        key = resource.class.name.demodulize.underscore.to_sym
        {key => resource}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
publish_my_data-1.0.4 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-1.0.3 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-1.0.2 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-1.0.1 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-1.0.0 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-0.0.32 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-0.0.31 app/controllers/concerns/publish_my_data/resource_rendering.rb
publish_my_data-0.0.30 app/controllers/concerns/publish_my_data/resource_rendering.rb