blacklight 6.0.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -6
  3. data/.rubocop_todo.yml +448 -87
  4. data/.travis.yml +1 -1
  5. data/VERSION +1 -1
  6. data/app/controllers/concerns/blacklight/bookmarks.rb +8 -8
  7. data/app/controllers/concerns/blacklight/catalog.rb +5 -5
  8. data/app/controllers/concerns/blacklight/controller.rb +5 -5
  9. data/app/controllers/concerns/blacklight/saved_searches.rb +4 -2
  10. data/app/controllers/concerns/blacklight/search_context.rb +3 -0
  11. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -1
  12. data/app/helpers/blacklight/blacklight_helper_behavior.rb +3 -3
  13. data/app/helpers/blacklight/catalog_helper_behavior.rb +20 -9
  14. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
  15. data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -1
  16. data/app/helpers/blacklight/facets_helper_behavior.rb +2 -2
  17. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -1
  18. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +18 -8
  19. data/app/helpers/blacklight/render_partials_helper.rb +15 -3
  20. data/app/models/concerns/blacklight/configurable.rb +4 -8
  21. data/app/models/concerns/blacklight/document.rb +3 -3
  22. data/app/models/concerns/blacklight/document/dublin_core.rb +1 -1
  23. data/app/models/concerns/blacklight/document/extensions.rb +1 -1
  24. data/app/models/concerns/blacklight/user.rb +1 -1
  25. data/app/models/record_mailer.rb +6 -1
  26. data/app/models/search.rb +2 -2
  27. data/blacklight.gemspec +5 -2
  28. data/config/locales/blacklight.de.yml +1 -0
  29. data/config/locales/blacklight.en.yml +1 -0
  30. data/config/locales/blacklight.es.yml +1 -0
  31. data/config/locales/blacklight.fr.yml +1 -0
  32. data/config/locales/blacklight.it.yml +1 -0
  33. data/config/locales/blacklight.pt-BR.yml +1 -0
  34. data/lib/blacklight.rb +2 -2
  35. data/lib/blacklight/abstract_repository.rb +2 -2
  36. data/lib/blacklight/configuration/field.rb +1 -1
  37. data/lib/blacklight/configuration/search_field.rb +1 -1
  38. data/lib/blacklight/configuration/sort_field.rb +1 -1
  39. data/lib/blacklight/search_builder.rb +8 -4
  40. data/lib/blacklight/search_state.rb +3 -3
  41. data/lib/blacklight/solr/repository.rb +3 -3
  42. data/lib/blacklight/solr/request.rb +2 -2
  43. data/lib/blacklight/solr/response.rb +1 -1
  44. data/lib/blacklight/solr/response/spelling.rb +1 -1
  45. data/lib/blacklight/solr/search_builder_behavior.rb +7 -7
  46. data/lib/blacklight/utils.rb +5 -5
  47. data/lib/generators/blacklight/assets_generator.rb +1 -1
  48. data/lib/generators/blacklight/controller_generator.rb +13 -15
  49. data/lib/generators/blacklight/document_generator.rb +5 -4
  50. data/lib/generators/blacklight/install_generator.rb +24 -27
  51. data/lib/generators/blacklight/models_generator.rb +18 -16
  52. data/lib/generators/blacklight/search_builder_generator.rb +4 -4
  53. data/lib/generators/blacklight/solr4_generator.rb +14 -9
  54. data/lib/generators/blacklight/solr5_generator.rb +1 -1
  55. data/lib/generators/blacklight/templates/{blacklight.css.scss → blacklight.scss} +0 -0
  56. data/lib/generators/blacklight/templates/solr_document.rb +6 -8
  57. data/lib/generators/blacklight/test_support_generator.rb +5 -3
  58. data/lib/generators/blacklight/user_generator.rb +18 -12
  59. data/lib/railties/blacklight.rake +2 -2
  60. data/tasks/blacklight.rake +1 -3
  61. metadata +17 -10
  62. data/.rubocop_hound.yml +0 -1063
data/.travis.yml CHANGED
@@ -17,7 +17,7 @@ matrix:
17
17
  - rvm: 2.2.4
18
18
  env: "RAILS_VERSION=4.2.5"
19
19
  - rvm: 2.3.0
20
- env: "RAILS_VERSION=5.0.0.beta2"
20
+ env: "RAILS_VERSION=5.0.0.beta3"
21
21
  - rvm: jruby-9.0.4.0
22
22
  env: "RAILS_VERSION=4.2.5 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
23
23
  allow_failures:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.2
1
+ 6.1.0
@@ -34,7 +34,7 @@ module Blacklight::Bookmarks
34
34
  # Blacklight uses #search_action_url to figure out the right URL for
35
35
  # the global search box
36
36
  def search_action_url *args
37
- search_catalog_url *args
37
+ search_catalog_url(*args)
38
38
  end
39
39
 
40
40
  def index
@@ -70,11 +70,11 @@ module Blacklight::Bookmarks
70
70
  # bookmark[title] and bookmark[document_id], but in that case #update
71
71
  # is simpler.
72
72
  def create
73
- if params[:bookmarks]
74
- @bookmarks = params[:bookmarks]
75
- else
76
- @bookmarks = [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
77
- end
73
+ @bookmarks = if params[:bookmarks]
74
+ params[:bookmarks]
75
+ else
76
+ [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
77
+ end
78
78
 
79
79
  current_or_guest_user.save! unless current_or_guest_user.persisted?
80
80
 
@@ -85,9 +85,9 @@ module Blacklight::Bookmarks
85
85
  if request.xhr?
86
86
  success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
87
87
  else
88
- if @bookmarks.length > 0 && success
88
+ if @bookmarks.any? && success
89
89
  flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length)
90
- elsif @bookmarks.length > 0
90
+ elsif @bookmarks.any?
91
91
  flash[:error] = I18n.t('blacklight.bookmarks.add.failure', :count => @bookmarks.length)
92
92
  end
93
93
 
@@ -58,7 +58,7 @@ module Blacklight::Catalog
58
58
  search_session['id'] = params[:search_id]
59
59
  search_session['per_page'] = params[:per_page]
60
60
 
61
- if params[:redirect] and (params[:redirect].starts_with?('/') or params[:redirect] =~ URI::regexp)
61
+ if params[:redirect] and (params[:redirect].starts_with?('/') or params[:redirect] =~ URI.regexp)
62
62
  path = URI.parse(params[:redirect]).path
63
63
  redirect_to path, status: 303
64
64
  else
@@ -141,11 +141,11 @@ module Blacklight::Catalog
141
141
  format.send key do
142
142
  case config
143
143
  when false
144
- raise ActionController::RoutingError.new('Not Found')
144
+ raise ActionController::RoutingError, 'Not Found'
145
145
  when Hash
146
146
  render config
147
147
  when Proc
148
- instance_exec &config
148
+ instance_exec(&config)
149
149
  when Symbol, String
150
150
  send config
151
151
  else
@@ -173,7 +173,7 @@ module Blacklight::Catalog
173
173
  if @response.export_formats.include? format_name
174
174
  render_document_export_format format_name
175
175
  else
176
- raise ActionController::UnknownFormat.new
176
+ raise ActionController::UnknownFormat
177
177
  end
178
178
  end
179
179
  end
@@ -192,7 +192,7 @@ module Blacklight::Catalog
192
192
  # By default, any search action from a Blacklight::Catalog controller
193
193
  # should use the current controller when constructing the route.
194
194
  def search_action_url options = {}
195
- raise "Options was not a hash (#{options.class}" unless options.is_a? Hash
195
+ raise ArgumentError, "Options was not a hash (#{options.class}" unless options.is_a? Hash
196
196
  # We don't want to permit here because one of the options could be :only_path, which is an option, but not a parameter
197
197
  # options.permit!
198
198
  url_for(options.merge(action: 'index'))
@@ -81,7 +81,7 @@ module Blacklight::Controller
81
81
  args.first[:only_path] = true
82
82
  end
83
83
 
84
- search_action_url *args
84
+ search_action_url(*args)
85
85
  end
86
86
 
87
87
  def search_facet_url options = {}
@@ -104,11 +104,11 @@ module Blacklight::Controller
104
104
  def current_or_guest_user
105
105
  if defined? super
106
106
  super
107
- else
108
- current_user if has_user_authentication_provider?
107
+ elsif has_user_authentication_provider?
108
+ current_user
109
109
  end
110
110
  end
111
- alias_method :blacklight_current_or_guest_user, :current_or_guest_user
111
+ alias blacklight_current_or_guest_user current_or_guest_user
112
112
 
113
113
  ##
114
114
  # We discard flash messages generated by the xhr requests to avoid
@@ -125,7 +125,7 @@ module Blacklight::Controller
125
125
  end
126
126
 
127
127
  def require_user_authentication_provider
128
- raise ActionController::RoutingError.new('Not Found') unless has_user_authentication_provider?
128
+ raise ActionController::RoutingError, 'Not Found' unless has_user_authentication_provider?
129
129
  end
130
130
 
131
131
  ##
@@ -32,11 +32,13 @@ module Blacklight
32
32
  # Only dereferences the user rather than removing the item in case it
33
33
  # is in the session[:history]
34
34
  def forget
35
- if search = current_user.searches.find(params[:id])
35
+ search = current_user.searches.find(params[:id])
36
+
37
+ if search.present?
36
38
  search.user_id = nil
37
39
  search.save
38
40
 
39
- flash[:notice] =I18n.t('blacklight.saved_searches.remove.success')
41
+ flash[:notice] = I18n.t('blacklight.saved_searches.remove.success')
40
42
  else
41
43
  flash[:error] = I18n.t('blacklight.saved_searches.remove.failure')
42
44
  end
@@ -21,6 +21,9 @@ module Blacklight::SearchContext
21
21
  # sets up the session[:search] hash if it doesn't already exist
22
22
  def search_session
23
23
  session[:search] ||= {}
24
+ # Need to call the getter again. The value is mutated
25
+ # https://github.com/rails/rails/issues/23884
26
+ session[:search]
24
27
  end
25
28
 
26
29
  # The current search session
@@ -29,7 +29,7 @@ module Blacklight::TokenBasedUser
29
29
  user_id, timestamp = message_encryptor.decrypt_and_verify(encrypted_user_id)
30
30
 
31
31
  if timestamp < 1.hour.ago
32
- raise Blacklight::Exceptions::ExpiredSessionToken.new
32
+ raise Blacklight::Exceptions::ExpiredSessionToken
33
33
  end
34
34
 
35
35
  user_id
@@ -111,7 +111,7 @@ module Blacklight::BlacklightHelperBehavior
111
111
  # @param [Blacklight::Solr::Response] response
112
112
  # @return [Boolean]
113
113
  def should_show_spellcheck_suggestions? response
114
- response.total <= spell_check_max and response.spelling.words.size > 0
114
+ response.total <= spell_check_max and response.spelling.words.any?
115
115
  end
116
116
 
117
117
  ##
@@ -256,7 +256,7 @@ module Blacklight::BlacklightHelperBehavior
256
256
  options = args.extract_options!
257
257
  document = args.first
258
258
  tag = options.fetch(:tag, :h4)
259
- document = document || @document
259
+ document ||= @document
260
260
 
261
261
  content_tag(tag, presenter(document).document_heading, itemprop: "name")
262
262
  end
@@ -307,7 +307,7 @@ module Blacklight::BlacklightHelperBehavior
307
307
  def with_format(format, &block)
308
308
  old_formats = formats
309
309
  self.formats = [format]
310
- block.call
310
+ yield
311
311
  self.formats = old_formats
312
312
  nil
313
313
  end
@@ -45,9 +45,18 @@ module Blacklight::CatalogHelperBehavior
45
45
  end
46
46
 
47
47
  case collection.total_count
48
- when 0; t('blacklight.search.pagination_info.no_items_found', :entry_name => entry_name ).html_safe
49
- when 1; t('blacklight.search.pagination_info.single_item_found', :entry_name => entry_name).html_safe
50
- else; t('blacklight.search.pagination_info.pages', :entry_name => entry_name, :current_page => collection.current_page, :num_pages => collection.total_pages, :start_num => number_with_delimiter(collection.offset_value + 1) , :end_num => number_with_delimiter(end_num), :total_num => number_with_delimiter(collection.total_count), :count => collection.total_pages).html_safe
48
+ when 0
49
+ t('blacklight.search.pagination_info.no_items_found', :entry_name => entry_name ).html_safe
50
+ when 1
51
+ t('blacklight.search.pagination_info.single_item_found', :entry_name => entry_name).html_safe
52
+ else
53
+ t('blacklight.search.pagination_info.pages', :entry_name => entry_name,
54
+ :current_page => collection.current_page,
55
+ :num_pages => collection.total_pages,
56
+ :start_num => number_with_delimiter(collection.offset_value + 1),
57
+ :end_num => number_with_delimiter(end_num),
58
+ :total_num => number_with_delimiter(collection.total_count),
59
+ :count => collection.total_pages).html_safe
51
60
  end
52
61
  end
53
62
 
@@ -72,7 +81,9 @@ module Blacklight::CatalogHelperBehavior
72
81
  # @see #page_entries_info
73
82
  # @return [String]
74
83
  def item_page_entry_info
75
- t('blacklight.search.entry_pagination_info.other', :current => number_with_delimiter(search_session['counter']), :total => number_with_delimiter(search_session['total']), :count => search_session['total'].to_i).html_safe
84
+ t('blacklight.search.entry_pagination_info.other', :current => number_with_delimiter(search_session['counter']),
85
+ :total => number_with_delimiter(search_session['total']),
86
+ :count => search_session['total'].to_i).html_safe
76
87
  end
77
88
 
78
89
  ##
@@ -258,11 +269,11 @@ module Blacklight::CatalogHelperBehavior
258
269
  if params['q'].present?
259
270
  q_label = label_for_search_field(params[:search_field]) unless default_search_field && params[:search_field] == default_search_field[:key]
260
271
 
261
- if q_label.present?
262
- constraints += [t('blacklight.search.page_title.constraint', label: q_label, value: params['q'])]
263
- else
264
- constraints += [params['q']]
265
- end
272
+ constraints += if q_label.present?
273
+ [t('blacklight.search.page_title.constraint', label: q_label, value: params['q'])]
274
+ else
275
+ [params['q']]
276
+ end
266
277
  end
267
278
 
268
279
  if params['f'].present?
@@ -90,7 +90,7 @@ module Blacklight::ConfigurationHelperBehavior
90
90
  defaults << field_config.label if field_config
91
91
  defaults << field.to_s.humanize
92
92
 
93
- field_label *defaults
93
+ field_label(*defaults)
94
94
  end
95
95
 
96
96
  def view_label view
@@ -14,7 +14,7 @@ module Blacklight
14
14
  Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).params_for_search instead')
15
15
  Blacklight::SearchState.new(args.first, blacklight_config).params_for_search(args.last)
16
16
  else
17
- raise ArgumentError.new "wrong number of arguments (#{args.length} for 0..2)"
17
+ raise ArgumentError, "wrong number of arguments (#{args.length} for 0..2)"
18
18
  end
19
19
  end
20
20
  deprecation_deprecate :params_for_search
@@ -38,10 +38,10 @@ module Blacklight::FacetsHelperBehavior
38
38
  # @option options [Hash] :locals locals to pass to the partial
39
39
  # @return [String]
40
40
  def render_facet_limit(display_facet, options = {})
41
- return if not should_render_facet?(display_facet)
41
+ return unless should_render_facet?(display_facet)
42
42
  options = options.dup
43
43
  options[:partial] ||= facet_partial_name(display_facet)
44
- options[:layout] ||= "facet_layout" unless options.has_key?(:layout)
44
+ options[:layout] ||= "facet_layout" unless options.key?(:layout)
45
45
  options[:locals] ||= {}
46
46
  options[:locals][:field_name] ||= display_facet.name
47
47
  options[:locals][:solr_field] ||= display_facet.name # deprecated
@@ -21,7 +21,7 @@ module Blacklight::HashAsHiddenFieldsHelperBehavior
21
21
 
22
22
  hidden_fields = []
23
23
  flatten_hash(hash).each do |name, value|
24
- value = [value] if !value.is_a?(Array)
24
+ value = Array.wrap(value)
25
25
  value.each do |v|
26
26
  hidden_fields << hidden_field_tag(name, v.to_s, :id => nil)
27
27
  end
@@ -9,7 +9,7 @@ module Blacklight::RenderConstraintsHelperBehavior
9
9
 
10
10
  ##
11
11
  # Check if the query has any constraints defined (a query, facet, etc)
12
- #
12
+ #
13
13
  # @param [Hash] query parameters
14
14
  # @return [Boolean]
15
15
  def query_has_constraints?(localized_params = params)
@@ -29,19 +29,30 @@ module Blacklight::RenderConstraintsHelperBehavior
29
29
  ##
30
30
  # Render the query constraints
31
31
  #
32
- # @param [Hash] query parameters
32
+ # @param [ActionController::Parameters] query parameters
33
33
  # @return [String]
34
34
  def render_constraints_query(localized_params = params)
35
35
  # So simple don't need a view template, we can just do it here.
36
- scope = localized_params.delete(:route_set) || self
37
36
  return "".html_safe if localized_params[:q].blank?
38
37
 
39
- options = localized_params.merge(:q=>nil, :action=>'index')
40
- options.permit!
41
38
  render_constraint_element(constraint_query_label(localized_params),
42
39
  localized_params[:q],
43
40
  classes: ["query"],
44
- remove: scope.url_for(options))
41
+ remove: remove_constraint_url(localized_params))
42
+ end
43
+
44
+ ##
45
+ # Provide a url for removing a particular constraint. This can be overriden
46
+ # in the case that you want parameters other than the defaults to be removed
47
+ # (e.g. :search_field)
48
+ #
49
+ # @param [ActionController::Parameters] localized_params query parameters
50
+ # @return [String]
51
+ def remove_constraint_url(localized_params)
52
+ scope = localized_params.delete(:route_set) || self
53
+ options = localized_params.merge(q: nil, action: 'index')
54
+ options.permit!
55
+ scope.url_for(options)
45
56
  end
46
57
 
47
58
  ##
@@ -92,7 +103,6 @@ module Blacklight::RenderConstraintsHelperBehavior
92
103
  # @option options [Array<String>] :classes an array of classes to add to container span for constraint.
93
104
  # @return [String]
94
105
  def render_constraint_element(label, value, options = {})
95
- render(:partial => "catalog/constraints_element", :locals => {:label => label, :value => value, :options => options})
106
+ render(:partial => "catalog/constraints_element", :locals => {:label => label, :value => value, :options => options})
96
107
  end
97
-
98
108
  end
@@ -87,7 +87,11 @@ module Blacklight::RenderPartialsHelper
87
87
  # first, the legacy template names for backwards compatbility
88
88
  # followed by the new, inheritable style
89
89
  # finally, a controller-specific path for non-catalog subclasses
90
- @document_index_path_templates ||= ["document_%{index_view_type}", "catalog/document_%{index_view_type}", "catalog/document_list"]
90
+ @document_index_path_templates ||= [
91
+ "document_%{index_view_type}",
92
+ "catalog/document_%{index_view_type}",
93
+ "catalog/document_list"
94
+ ]
91
95
  end
92
96
 
93
97
 
@@ -128,7 +132,7 @@ module Blacklight::RenderPartialsHelper
128
132
  def document_partial_name(document, base_name = nil)
129
133
  view_config = blacklight_config.view_config(:show)
130
134
 
131
- display_type = if base_name and view_config.has_key? :"#{base_name}_display_type_field"
135
+ display_type = if base_name and view_config.key? :"#{base_name}_display_type_field"
132
136
  document[view_config[:"#{base_name}_display_type_field"]]
133
137
  end
134
138
 
@@ -152,7 +156,15 @@ module Blacklight::RenderPartialsHelper
152
156
  # first, the legacy template names for backwards compatbility
153
157
  # followed by the new, inheritable style
154
158
  # finally, a controller-specific path for non-catalog subclasses
155
- @partial_path_templates ||= ["%{action_name}_%{index_view_type}_%{format}", "%{action_name}_%{index_view_type}_default", "%{action_name}_%{format}", "%{action_name}_default", "catalog/%{action_name}_%{format}", "catalog/_%{action_name}_partials/%{format}", "catalog/_%{action_name}_partials/default"]
159
+ @partial_path_templates ||= [
160
+ "%{action_name}_%{index_view_type}_%{format}",
161
+ "%{action_name}_%{index_view_type}_default",
162
+ "%{action_name}_%{format}",
163
+ "%{action_name}_default",
164
+ "catalog/%{action_name}_%{format}",
165
+ "catalog/_%{action_name}_partials/%{format}",
166
+ "catalog/_%{action_name}_partials/default"
167
+ ]
156
168
  end
157
169
 
158
170
  private
@@ -23,15 +23,11 @@ module Blacklight::Configurable
23
23
  # object' that won't be automatically available to subclasses, that's why
24
24
  # we lazy load to 'inherit' how we want.
25
25
  def blacklight_config
26
- unless (defined? @blacklight_config)
27
- if superclass.respond_to?(:blacklight_config)
28
- @blacklight_config = superclass.blacklight_config.deep_copy
29
- else
30
- @blacklight_config = default_configuration
31
- end
26
+ @blacklight_config ||= if superclass.respond_to?(:blacklight_config)
27
+ superclass.blacklight_config.deep_copy
28
+ else
29
+ default_configuration
32
30
  end
33
-
34
- return @blacklight_config
35
31
  end
36
32
  attr_writer :blacklight_config
37
33
 
@@ -86,18 +86,18 @@ module Blacklight::Document
86
86
  end
87
87
  end
88
88
  end
89
- alias_method :has_field?, :has?
89
+ alias has_field? has?
90
90
 
91
91
  def key? k
92
92
  _source.key? k
93
93
  end
94
- alias_method :has_key?, :key?
94
+ alias has_key? key?
95
95
 
96
96
  def fetch key, *default
97
97
  if key? key
98
98
  self[key]
99
99
  elsif default.empty? and !block_given?
100
- raise KeyError.new("key not found \"#{key}\"")
100
+ raise KeyError, "key not found \"#{key}\""
101
101
  else
102
102
  (yield(self) if block_given?) || default.first
103
103
  end
@@ -26,7 +26,7 @@ module Blacklight::Document::DublinCore
26
26
  'xmlns:oai_dc' => "http://www.openarchives.org/OAI/2.0/oai_dc/",
27
27
  'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
28
28
  'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
29
- 'xsi:schemaLocation' => %{http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd}) do
29
+ 'xsi:schemaLocation' => %(http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd)) do
30
30
  self.to_semantic_values.select { |field, values| dublin_core_field_name? field }.each do |field,values|
31
31
  Array.wrap(values).each do |v|
32
32
  xml.tag! "dc:#{field}", v
@@ -6,7 +6,7 @@
6
6
  # extension can be registered with your document class, along with a block
7
7
  # containing custom logic for which documents to apply the extension to.
8
8
  #
9
- # SolrDocument.use_extension(MyExtension) {|document| my_logic_on_document(document}
9
+ # SolrDocument.use_extension(MyExtension) { |document| my_logic_on_document(document) }
10
10
  #
11
11
  # MyExtension will be mixed-in (using ruby 'extend') only to those documents
12
12
  # where the block results in true.
@@ -12,7 +12,7 @@ module Blacklight::User
12
12
  end
13
13
 
14
14
  def bookmarks_for_documents documents = []
15
- if documents.length > 0
15
+ if documents.any?
16
16
  bookmarks.where(document_type: documents.first.class.base_class.to_s, document_id: documents.map(&:id))
17
17
  else
18
18
  []