app/controllers/qa/terms_controller.rb in qa-0.10.1 vs app/controllers/qa/terms_controller.rb in qa-0.10.2

- old
+ new

@@ -2,11 +2,10 @@ # params and figure out which class to instantiate based on the "vocab" param. # All the authority classes inherit from a super class so they implement the # same methods. class Qa::TermsController < ApplicationController - before_action :check_vocab_param, :init_authority before_action :check_query_param, only: :search # If the subauthority supports it, return a list of all terms in the authority def index @@ -30,22 +29,22 @@ end def init_authority begin mod = authority_class.camelize.constantize - rescue NameError => e + rescue NameError logger.warn "Unable to initialize authority #{authority_class}" head :not_found return end begin - @authority = if mod.kind_of? Class - mod.new - else - raise Qa::MissingSubAuthority, "No sub-authority provided" if params[:subauthority].blank? - mod.subauthority_for(params[:subauthority]) - end + @authority = if mod.is_a? Class + mod.new + else + raise Qa::MissingSubAuthority, "No sub-authority provided" if params[:subauthority].blank? + mod.subauthority_for(params[:subauthority]) + end rescue Qa::InvalidSubAuthority, Qa::MissingSubAuthority => e logger.warn e.message head :not_found end end @@ -54,15 +53,14 @@ head :not_found unless params[:q].present? end private - def authority_class - "Qa::Authorities::"+params[:vocab].capitalize - end + def authority_class + "Qa::Authorities::" + params[:vocab].capitalize + end - # converts wildcards into URL-encoded characters - def url_search - params[:q].gsub("*", "%2A") - end - + # converts wildcards into URL-encoded characters + def url_search + params[:q].gsub("*", "%2A") + end end