Sha256: d4f4cb91028b00714740047f2e0673db9a735bc87a13d074db78a2d2b21be85c

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

module FcrepoAdmin::Controller
  module ControllerBehavior
    extend ActiveSupport::Concern

    included do
      helper_method :object_is_governed_by
    end

    protected

    def load_and_authorize_object
      load_object
      authorize_object
    end

    def load_object
      pid = params[:object_id] || params[:id]
      begin
        @object = ActiveFedora::Base.find(pid, :cast => true)
      rescue ActiveFedora::ObjectNotFoundError
        render :text => "Object not found", :status => 404
      end
    end

    def authorize_object
      authorize! params[:action].to_sym, @object
    end

    def object_is_governed_by
      @object_is_governed_by ||= @object.send(@object.governed_by_association.name) rescue nil
    end

    # #solr_response_for_raw_result and #solr_documents_for_response
    # duplicate Blacklight functionality outside of a full Blacklight
    # catalog controller context.
    def solr_response_for_raw_result(solr_result)
      Blacklight::SolrResponse.new(solr_result, {})
    end

    def solr_documents_for_response(solr_response)
      solr_response.docs.collect { |doc| SolrDocument.new(doc, solr_response) }
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fcrepo_admin-0.6.1 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.6.0 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.5 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.5.pre lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.4 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.3 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.2 lib/fcrepo_admin/controller/controller_behavior.rb
fcrepo_admin-0.5.1 lib/fcrepo_admin/controller/controller_behavior.rb