Skip to content

Commit

Permalink
Change method visibility from protected to private
Browse files Browse the repository at this point in the history
I don't see why any of these needs protected visibility.
  • Loading branch information
jcoyne committed May 11, 2017
1 parent a9baa14 commit 34a5da2
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/bookmarks.rb
Expand Up @@ -129,7 +129,7 @@ def clear
redirect_to :action => "index"
end

protected
private

def verify_user
unless current_or_guest_user || (action == "index" && token_or_current_or_guest_user)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/catalog.rb
Expand Up @@ -140,7 +140,7 @@ def facet_limit_for(facet_field)
end
end

protected
private

#
# non-routable methods ->
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/controller.rb
Expand Up @@ -50,7 +50,7 @@ def default_catalog_controller

delegate :blacklight_config, to: :default_catalog_controller

protected
private

##
# Context in which to evaluate blacklight configuration conditionals
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/saved_searches.rb
Expand Up @@ -63,7 +63,7 @@ def clear
redirect_to blacklight.saved_searches_url
end

protected
private

def verify_user
flash[:notice] = I18n.t('blacklight.saved_searches.need_login') && raise(Blacklight::Exceptions::AccessDenied) unless current_user
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/blacklight/search_context.rb
Expand Up @@ -15,7 +15,7 @@ def record_search_parameters opts = { only: :index }
end
end

protected
private

# sets up the session[:search] hash if it doesn't already exist
def search_session
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/concerns/blacklight/token_based_user.rb
Expand Up @@ -10,7 +10,7 @@ module Blacklight::TokenBasedUser
end
end

protected
private

def token_or_current_or_guest_user
token_user || current_or_guest_user
Expand Down Expand Up @@ -49,8 +49,6 @@ def message_encryptor
ActiveSupport::MessageEncryptor.new(export_secret_token)
end

private

# Ruby 2.4 requires keys of very particular lengths
def key_len
if ActiveSupport::MessageEncryptor.respond_to? :key_len
Expand Down
Expand Up @@ -28,7 +28,7 @@ def render_hash_as_hidden_fields(hash)
safe_join(hidden_fields, "\n")
end

protected
private

def flatten_hash(hash = params, ancestor_names = [])
flat_hash = {}
Expand Down
42 changes: 20 additions & 22 deletions app/helpers/blacklight/render_partials_helper_behavior.rb
Expand Up @@ -96,26 +96,6 @@ def document_index_path_templates
]
end

protected

##
# Return a partial name for rendering a document
# this method can be overridden in order to transform the value
# (e.g. 'PdfBook' => 'pdf_book')
#
# @param [SolrDocument] document
# @param [String, Array] display_type a value suggestive of a partial
# @return [String] the name of the partial to render
# @example
# type_field_to_partial_name(['a book-article'])
# => 'a_book_article'
def type_field_to_partial_name(_document, display_type)
# using "_" as sep. to more closely follow the views file naming conventions
# parameterize uses "-" as the default sep. which throws errors
underscore = '_'.freeze
Array(display_type).join(' '.freeze).tr('-'.freeze, underscore).parameterize(separator: underscore)
end

##
# Return a normalized partial name for rendering a single document
#
Expand All @@ -136,6 +116,26 @@ def document_partial_name(document, base_name = nil)
type_field_to_partial_name(document, display_type)
end

private

##
# Return a partial name for rendering a document
# this method can be overridden in order to transform the value
# (e.g. 'PdfBook' => 'pdf_book')
#
# @param [SolrDocument] document
# @param [String, Array] display_type a value suggestive of a partial
# @return [String] the name of the partial to render
# @example
# type_field_to_partial_name(['a book-article'])
# => 'a_book_article'
def type_field_to_partial_name(_document, display_type)
# using "_" as sep. to more closely follow the views file naming conventions
# parameterize uses "-" as the default sep. which throws errors
underscore = '_'.freeze
Array(display_type).join(' '.freeze).tr('-'.freeze, underscore).parameterize(separator: underscore)
end

##
# A list of document partial templates to try to render for a document
#
Expand All @@ -161,8 +161,6 @@ def document_partial_path_templates
]
end

private

def find_document_show_template_with_view view_type, base_name, format, locals
document_partial_path_templates.each do |str|
partial = format(str, action_name: base_name, format: format, index_view_type: view_type)
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/blacklight/url_helper_behavior.rb
Expand Up @@ -26,7 +26,7 @@ def link_to_document(doc, field_or_opts = nil, opts = { :counter => nil })
def document_link_params(doc, opts)
session_tracking_params(doc, opts[:counter]).deep_merge(opts.except(:label, :counter))
end
protected :document_link_params
private :document_link_params

##
# Link to the previous document in the current search context
Expand Down Expand Up @@ -62,7 +62,7 @@ def session_tracking_params document, counter

{ data: { :'context-href' => path } }
end
protected :session_tracking_params
private :session_tracking_params

##
# Get the URL for tracking search sessions across pages using polymorphic routing
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/blacklight/rendering/abstract_step.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(values, config, document, context, options, stack)

attr_reader :values, :config, :document, :context, :options, :stack

protected
private

def next_step(output_values)
first, *rest = *stack
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/blacklight/rendering/pipeline.rb
Expand Up @@ -26,7 +26,7 @@ def render
first.new(values, config, document, context, options, rest).render
end

protected
private

# Ordered list of operations, Terminator must be at the end.
def stack
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/abstract_repository.rb
Expand Up @@ -32,7 +32,7 @@ def search(_params = {})
raise NotImplementedError
end

protected
private

def connection_config
blacklight_config.connection_config
Expand Down
4 changes: 1 addition & 3 deletions lib/blacklight/configuration/fields.rb
Expand Up @@ -135,7 +135,7 @@ def add_blacklight_field config_key, *args, &block
self[config_key.pluralize][field_config.key] = field_config
end

protected
private

def luke_fields
if @table[:luke_fields] == false
Expand Down Expand Up @@ -194,8 +194,6 @@ def hash_arg_to_config(hash_arg, klass)
end
end

private

# convert a config key to the appropriate Field class
def field_class_from_key key
"Blacklight::Configuration::#{key.camelcase}".constantize
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/search_builder.rb
Expand Up @@ -235,7 +235,7 @@ def search_field
blacklight_config.search_fields[blacklight_params[:search_field]]
end

protected
private

def request
Blacklight::Solr::Request.new
Expand Down
2 changes: 1 addition & 1 deletion lib/blacklight/solr/repository.rb
Expand Up @@ -49,7 +49,7 @@ def send_and_receive(path, solr_params = {})
raise Blacklight::Exceptions::InvalidRequest, e.message
end

protected
private

def build_connection
RSolr.connect(connection_config.merge(adapter: connection_config[:http_adapter]))
Expand Down
23 changes: 14 additions & 9 deletions spec/helpers/blacklight/render_partials_helper_behavior_spec.rb
@@ -1,21 +1,26 @@
RSpec.describe Blacklight::RenderPartialsHelperBehavior do
describe "#type_field_to_partial_name" do
let(:document) { double }
subject { helper.send(:type_field_to_partial_name, document, value) }

context "with default value" do
subject { helper.type_field_to_partial_name(document, 'default') }
it { should eq 'default' }
let(:value) { 'default' }
it { is_expected.to eq 'default' }
end

context "with spaces" do
subject { helper.type_field_to_partial_name(document, 'one two three') }
it { should eq 'one_two_three' }
let(:value) { 'one two three' }
it { is_expected.to eq 'one_two_three' }
end

context "with hyphens" do
subject { helper.type_field_to_partial_name(document, 'one-two-three') }
it { should eq 'one_two_three' }
let(:value) { 'one-two-three' }
it { is_expected.to eq 'one_two_three' }
end

context "an array" do
subject { helper.type_field_to_partial_name(document, ['one', 'two', 'three']) }
it { should eq 'one_two_three' }
let(:value) { ['one', 'two', 'three'] }
it { is_expected.to eq 'one_two_three' }
end
end

Expand Down Expand Up @@ -72,4 +77,4 @@
end
end

end
end

0 comments on commit 34a5da2

Please sign in to comment.