Sha256: 4ee098a3efb17461cf3e2be4cc1813eed61beac4a82b204734203f0902f7de22

Contents?: true

Size: 1.32 KB

Versions: 37

Compression:

Stored size: 1.32 KB

Contents

# Include this module into any of your Controller classes to add Hydra functionality
#
# @example
#  class CustomHydraController < ApplicationController
#    include Hydra::Controller::ControllerBehavior
#  end
#
module Hydra::Controller::ControllerBehavior
  extend ActiveSupport::Concern

  included do
    # Catch permission errors
    rescue_from CanCan::AccessDenied, with: :deny_access
  end

  # get the currently configured user identifier.  Can be overridden to return whatever (ie. login, email, etc)
  # defaults to using whatever you have set as the Devise authentication_key
  def user_key
    current_user.user_key if current_user
  end

  # Override this method if you wish to customize the way access is denied
  def deny_access(exception)
    if exception.action == :edit
      redirect_to(main_app.url_for(action: 'show'), alert: exception.message)
    elsif current_user and current_user.persisted?
      redirect_to main_app.root_path, alert: exception.message
    else
      session['user_return_to'.freeze] = request.url
      redirect_to main_app.new_user_session_path, alert: exception.message
    end
  end

  module ClassMethods
    # get the solr name for a field with this name and using the given solrizer descriptor
    def solr_name(name, *opts)
      ActiveFedora.index_field_mapper.solr_name(name, *opts)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
hydra-core-13.0.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-12.1.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-12.0.2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.7 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-12.0.1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.6 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.5 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.4 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-12.0.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.0.rc2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.7.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.6.2 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.6.1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.6.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.5.1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-11.0.0.rc1 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.5.0 app/controllers/concerns/hydra/controller/controller_behavior.rb
hydra-core-10.4.0 app/controllers/concerns/hydra/controller/controller_behavior.rb