blacklight 6.5.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +114 -213
- data/{.solr_wrapper → .solr_wrapper.yml} +0 -0
- data/.yardopts +3 -1
- data/Gemfile +0 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/Vagrantfile +0 -2
- data/app/controllers/bookmarks_controller.rb +0 -2
- data/app/controllers/catalog_controller.rb +0 -2
- data/app/controllers/concerns/blacklight/base.rb +0 -1
- data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -11
- data/app/controllers/concerns/blacklight/controller.rb +11 -7
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +24 -37
- data/app/controllers/concerns/blacklight/facet.rb +2 -11
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -3
- data/app/controllers/concerns/blacklight/search_context.rb +0 -1
- data/app/controllers/concerns/blacklight/search_fields.rb +2 -2
- data/app/controllers/concerns/blacklight/search_helper.rb +14 -24
- data/app/controllers/concerns/blacklight/token_based_user.rb +0 -2
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +27 -28
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -15
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -5
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -3
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +21 -25
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -2
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +8 -9
- data/app/helpers/blacklight/render_partials_helper.rb +14 -13
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -4
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/models/blacklight/facet_paginator.rb +2 -2
- data/app/models/concerns/blacklight/document.rb +1 -6
- data/app/models/concerns/blacklight/document/active_model_shim.rb +0 -1
- data/app/models/concerns/blacklight/document/cache_key.rb +3 -3
- data/app/models/concerns/blacklight/document/dublin_core.rb +0 -1
- data/app/models/concerns/blacklight/document/email.rb +0 -2
- data/app/models/concerns/blacklight/document/export.rb +1 -2
- data/app/models/concerns/blacklight/document/schema_org.rb +0 -2
- data/app/models/concerns/blacklight/document/sms.rb +0 -2
- data/app/models/concerns/blacklight/solr/document.rb +0 -1
- data/app/models/record_mailer.rb +0 -1
- data/app/models/solr_document.rb +0 -2
- data/app/presenters/blacklight/document_presenter.rb +14 -11
- data/app/presenters/blacklight/index_presenter.rb +5 -5
- data/app/presenters/blacklight/json_presenter.rb +0 -1
- data/app/presenters/blacklight/rendering/abstract_step.rb +0 -1
- data/app/presenters/blacklight/rendering/helper_method.rb +5 -5
- data/app/presenters/blacklight/rendering/link_to_facet.rb +1 -1
- data/app/presenters/blacklight/show_presenter.rb +4 -5
- data/app/services/blacklight/field_retriever.rb +8 -9
- data/app/views/catalog/_facet_limit.html.erb +1 -1
- data/blacklight.gemspec +4 -0
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/abstract_repository.rb +4 -3
- data/lib/blacklight/configuration.rb +57 -92
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/fields.rb +24 -7
- data/lib/blacklight/exceptions.rb +0 -2
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/search_builder.rb +92 -96
- data/lib/blacklight/search_state.rb +2 -1
- data/lib/blacklight/solr/repository.rb +3 -4
- data/lib/blacklight/solr/request.rb +0 -2
- data/lib/blacklight/solr/response/facets.rb +23 -28
- data/lib/blacklight/solr/response/group.rb +0 -1
- data/lib/blacklight/solr/response/group_response.rb +1 -5
- data/lib/blacklight/solr/response/pagination_methods.rb +0 -1
- data/lib/blacklight/solr/response/response.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +0 -4
- data/lib/blacklight/solr/search_builder_behavior.rb +29 -41
- data/lib/blacklight/utils.rb +10 -7
- data/lib/generators/blacklight/assets_generator.rb +0 -1
- data/lib/generators/blacklight/document_generator.rb +0 -1
- data/lib/generators/blacklight/install_generator.rb +2 -6
- data/lib/generators/blacklight/models_generator.rb +0 -3
- data/lib/generators/blacklight/search_builder_generator.rb +0 -1
- data/lib/generators/blacklight/solr4_generator.rb +0 -2
- data/lib/generators/blacklight/solr5_generator.rb +15 -1
- data/lib/generators/blacklight/test_support_generator.rb +0 -1
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -4
- data/spec/controllers/blacklight/search_helper_spec.rb +5 -7
- data/spec/controllers/blacklight/suggest_search_spec.rb +2 -2
- data/spec/controllers/bookmarks_controller_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +6 -6
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_formats_spec.rb +0 -6
- data/spec/helpers/blacklight_helper_spec.rb +7 -7
- data/spec/helpers/catalog_helper_spec.rb +10 -10
- data/spec/helpers/configuration_helper_spec.rb +3 -3
- data/spec/helpers/facets_helper_spec.rb +1 -2
- data/spec/helpers/render_constraints_helper_spec.rb +8 -0
- data/spec/integration/generators/blacklight/solr5_generator_spec.rb +60 -0
- data/spec/models/blacklight/document_spec.rb +1 -1
- data/spec/models/blacklight/search_builder_spec.rb +5 -4
- data/spec/models/blacklight/solr/search_builder_spec.rb +12 -18
- data/spec/presenters/pipeline_spec.rb +1 -1
- data/spec/spec_helper.rb +43 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -1
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
- data/tasks/blacklight.rake +3 -0
- metadata +61 -3
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight::Solr
|
3
3
|
class Repository < Blacklight::AbstractRepository
|
4
|
-
|
5
4
|
##
|
6
5
|
# Find a single solr document result (by id) using the document configuration
|
7
|
-
# @param [String] document's unique key value
|
8
|
-
# @param [Hash] additional solr query parameters
|
6
|
+
# @param [String] id document's unique key value
|
7
|
+
# @param [Hash] params additional solr query parameters
|
9
8
|
def find id, params = {}
|
10
9
|
doc_params = params.reverse_merge(blacklight_config.default_document_solr_params)
|
11
10
|
.reverse_merge(qt: blacklight_config.document_solr_request_handler)
|
@@ -18,7 +17,7 @@ module Blacklight::Solr
|
|
18
17
|
|
19
18
|
##
|
20
19
|
# Execute a search query against solr
|
21
|
-
# @param [Hash] solr query parameters
|
20
|
+
# @param [Hash] params solr query parameters
|
22
21
|
def search params = {}
|
23
22
|
send_and_receive blacklight_config.solr_path, params.reverse_merge(qt: blacklight_config.qt)
|
24
23
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
3
3
|
|
4
4
|
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
5
|
-
|
6
5
|
SINGULAR_KEYS = %w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
|
7
6
|
ARRAY_KEYS = %w(facet.field facet.query facet.pivot fq hl.fl)
|
8
7
|
|
@@ -41,5 +40,4 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
|
41
40
|
def to_hash
|
42
41
|
reject {|key, value| ARRAY_KEYS.include?(key) && value.blank?}
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
@@ -60,6 +60,7 @@ module Blacklight::Solr::Response::Facets
|
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
63
|
+
|
63
64
|
# Per https://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
|
64
65
|
def solr_default_limit
|
65
66
|
100
|
@@ -95,7 +96,7 @@ module Blacklight::Solr::Response::Facets
|
|
95
96
|
@facet_counts ||= self['facet_counts'] || {}
|
96
97
|
end
|
97
98
|
|
98
|
-
# Returns the hash of all the facet_fields (ie: {'instock_b' => ['true', 123, 'false', 20]}
|
99
|
+
# Returns the hash of all the facet_fields (ie: { 'instock_b' => ['true', 123, 'false', 20] }
|
99
100
|
def facet_fields
|
100
101
|
@facet_fields ||= begin
|
101
102
|
val = facet_counts['facet_fields'] || {}
|
@@ -120,6 +121,7 @@ module Blacklight::Solr::Response::Facets
|
|
120
121
|
end
|
121
122
|
|
122
123
|
private
|
124
|
+
|
123
125
|
##
|
124
126
|
# Convert Solr responses of various json.nl flavors to
|
125
127
|
def list_as_hash solr_list
|
@@ -144,8 +146,7 @@ module Blacklight::Solr::Response::Facets
|
|
144
146
|
# a hash of Blacklight::Solr::Response::Facet::FacetField objects
|
145
147
|
def facet_field_aggregations
|
146
148
|
list_as_hash(facet_fields).each_with_object({}) do |(facet_field_name, values), hash|
|
147
|
-
items =
|
148
|
-
values.each do |value, hits|
|
149
|
+
items = values.map do |value, hits|
|
149
150
|
i = FacetItem.new(value: value, hits: hits)
|
150
151
|
|
151
152
|
# solr facet.missing serialization
|
@@ -154,7 +155,7 @@ module Blacklight::Solr::Response::Facets
|
|
154
155
|
i.fq = "-#{facet_field_name}:[* TO *]"
|
155
156
|
end
|
156
157
|
|
157
|
-
|
158
|
+
i
|
158
159
|
end
|
159
160
|
|
160
161
|
options = facet_field_aggregation_options(facet_field_name)
|
@@ -162,12 +163,10 @@ module Blacklight::Solr::Response::Facets
|
|
162
163
|
items,
|
163
164
|
options)
|
164
165
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end
|
170
|
-
end
|
166
|
+
# alias all the possible blacklight config names..
|
167
|
+
blacklight_config.facet_fields.select { |k,v| v.field == facet_field_name }.each do |key,_|
|
168
|
+
hash[key] = hash[facet_field_name]
|
169
|
+
end if blacklight_config and !blacklight_config.facet_fields[facet_field_name]
|
171
170
|
end
|
172
171
|
end
|
173
172
|
|
@@ -196,11 +195,10 @@ module Blacklight::Solr::Response::Facets
|
|
196
195
|
|
197
196
|
blacklight_config.facet_fields.select { |k,v| v.query }.each_with_object({}) do |(field_name, facet_field), hash|
|
198
197
|
salient_facet_queries = facet_field.query.map { |k, x| x[:fq] }
|
199
|
-
items =
|
200
|
-
facet_queries.select { |k,v| salient_facet_queries.include?(k) }.reject { |value, hits| hits == 0 }.map do |value,hits|
|
198
|
+
items = facet_queries.select { |k,v| salient_facet_queries.include?(k) }.reject { |value, hits| hits.zero? }.map do |value,hits|
|
201
199
|
salient_fields = facet_field.query.select { |key, val| val[:fq] == value }
|
202
200
|
key = ((salient_fields.keys if salient_fields.respond_to? :keys) || salient_fields.first).first
|
203
|
-
|
201
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(value: key, hits: hits, label: facet_field.query[key][:label])
|
204
202
|
end
|
205
203
|
|
206
204
|
hash[field_name] = Blacklight::Solr::Response::Facets::FacetField.new field_name, items
|
@@ -212,28 +210,25 @@ module Blacklight::Solr::Response::Facets
|
|
212
210
|
# a hash of Blacklight::Solr::Response::Facet::FacetField objects
|
213
211
|
def facet_pivot_aggregations
|
214
212
|
facet_pivot.each_with_object({}) do |(field_name, values), hash|
|
215
|
-
|
216
|
-
values.map do |lst|
|
217
|
-
items << construct_pivot_field(lst)
|
218
|
-
end
|
213
|
+
next unless blacklight_config and !blacklight_config.facet_fields[field_name]
|
219
214
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
215
|
+
items = values.map do |lst|
|
216
|
+
construct_pivot_field(lst)
|
217
|
+
end
|
218
|
+
|
219
|
+
# alias all the possible blacklight config names..
|
220
|
+
blacklight_config.facet_fields.select { |k,v| v.pivot and v.pivot.join(",") == field_name }.each do |key, _|
|
221
|
+
hash[key] = Blacklight::Solr::Response::Facets::FacetField.new key, items
|
222
|
+
end
|
226
223
|
end
|
227
224
|
end
|
228
225
|
|
229
226
|
##
|
230
227
|
# Recursively parse the pivot facet response to build up the full pivot tree
|
231
228
|
def construct_pivot_field lst, parent_fq = {}
|
232
|
-
items = []
|
233
|
-
|
234
|
-
|
235
|
-
items << construct_pivot_field(i, parent_fq.merge({ lst[:field] => lst[:value] }))
|
236
|
-
end if lst[:pivot]
|
229
|
+
items = Array(lst[:pivot]).map do |i|
|
230
|
+
construct_pivot_field(i, parent_fq.merge({ lst[:field] => lst[:value] }))
|
231
|
+
end
|
237
232
|
|
238
233
|
Blacklight::Solr::Response::Facets::FacetItem.new(value: lst[:value], hits: lst[:count], field: lst[:field], items: items, fq: parent_fq)
|
239
234
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class Blacklight::Solr::Response::GroupResponse
|
3
|
-
|
4
3
|
include Blacklight::Solr::Response::PaginationMethods
|
5
4
|
|
6
5
|
attr_reader :key, :group, :response
|
@@ -34,17 +33,14 @@ class Blacklight::Solr::Response::GroupResponse
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def method_missing meth, *args, &block
|
37
|
-
|
38
36
|
if response.respond_to? meth
|
39
37
|
response.send(meth, *args, &block)
|
40
38
|
else
|
41
39
|
super
|
42
40
|
end
|
43
|
-
|
44
41
|
end
|
45
42
|
|
46
|
-
def
|
43
|
+
def respond_to_missing? meth, include_private = false
|
47
44
|
response.respond_to?(meth) || super
|
48
45
|
end
|
49
|
-
|
50
46
|
end
|
@@ -4,13 +4,11 @@
|
|
4
4
|
# response.spelling.words
|
5
5
|
#
|
6
6
|
module Blacklight::Solr::Response::Spelling
|
7
|
-
|
8
7
|
def spelling
|
9
8
|
@spelling ||= Base.new(self)
|
10
9
|
end
|
11
10
|
|
12
11
|
class Base
|
13
|
-
|
14
12
|
attr_reader :response
|
15
13
|
|
16
14
|
def initialize(response)
|
@@ -88,7 +86,5 @@ module Blacklight::Solr::Response::Spelling
|
|
88
86
|
end
|
89
87
|
end
|
90
88
|
end
|
91
|
-
|
92
89
|
end
|
93
|
-
|
94
90
|
end
|
@@ -70,7 +70,7 @@ module Blacklight::Solr
|
|
70
70
|
"{!lucene}NOT *:*"
|
71
71
|
else
|
72
72
|
"{!lucene}" + q.map do |field, values|
|
73
|
-
"#{field}:(#{Array(values).map { |x| solr_param_quote(x) }.join(
|
73
|
+
"#{field}:(#{Array(values).map { |x| solr_param_quote(x) }.join(' OR ')})"
|
74
74
|
end.join(" AND ")
|
75
75
|
end
|
76
76
|
|
@@ -84,7 +84,6 @@ module Blacklight::Solr
|
|
84
84
|
# Add any existing facet limits, stored in app-level HTTP query
|
85
85
|
# as :f, to solr as appropriate :fq query.
|
86
86
|
def add_facet_fq_to_solr(solr_parameters)
|
87
|
-
|
88
87
|
# convert a String value into an Array
|
89
88
|
if solr_parameters[:fq].is_a? String
|
90
89
|
solr_parameters[:fq] = [solr_parameters[:fq]]
|
@@ -95,8 +94,7 @@ module Blacklight::Solr
|
|
95
94
|
f_request_params = blacklight_params[:f]
|
96
95
|
|
97
96
|
f_request_params.each_pair do |facet_field, value_list|
|
98
|
-
Array(value_list).each do |value|
|
99
|
-
next if value.blank? # skip empty strings
|
97
|
+
Array(value_list).reject(&:blank?).each do |value|
|
100
98
|
solr_parameters.append_filter_query facet_value_to_fq_string(facet_field, value)
|
101
99
|
end
|
102
100
|
end
|
@@ -111,13 +109,12 @@ module Blacklight::Solr
|
|
111
109
|
facet_fields_to_include_in_request.each do |field_name, facet|
|
112
110
|
solr_parameters[:facet] ||= true
|
113
111
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
solr_parameters.append_facet_fields with_ex_local_param(facet.ex, facet.field)
|
112
|
+
if facet.pivot
|
113
|
+
solr_parameters.append_facet_pivot with_ex_local_param(facet.ex, facet.pivot.join(","))
|
114
|
+
elsif facet.query
|
115
|
+
solr_parameters.append_facet_query facet.query.map { |k, x| with_ex_local_param(facet.ex, x[:fq]) }
|
116
|
+
else
|
117
|
+
solr_parameters.append_facet_fields with_ex_local_param(facet.ex, facet.field)
|
121
118
|
end
|
122
119
|
|
123
120
|
if facet.sort
|
@@ -137,11 +134,9 @@ module Blacklight::Solr
|
|
137
134
|
|
138
135
|
def add_solr_fields_to_query solr_parameters
|
139
136
|
blacklight_config.show_fields.select(&method(:should_add_field_to_request?)).each do |field_name, field|
|
140
|
-
|
141
|
-
field.
|
142
|
-
|
143
|
-
end
|
144
|
-
end
|
137
|
+
field.solr_params.each do |k, v|
|
138
|
+
solr_parameters[:"f.#{field.field}.#{k}"] = v
|
139
|
+
end if field.solr_params
|
145
140
|
end
|
146
141
|
|
147
142
|
blacklight_config.index_fields.select(&method(:should_add_field_to_request?)).each do |field_name, field|
|
@@ -150,11 +145,9 @@ module Blacklight::Solr
|
|
150
145
|
solr_parameters.append_highlight_field field.field
|
151
146
|
end
|
152
147
|
|
153
|
-
|
154
|
-
field.
|
155
|
-
|
156
|
-
end
|
157
|
-
end
|
148
|
+
field.solr_params.each do |k, v|
|
149
|
+
solr_parameters[:"f.#{field.field}.#{k}"] = v
|
150
|
+
end if field.solr_params
|
158
151
|
end
|
159
152
|
end
|
160
153
|
|
@@ -166,9 +159,7 @@ module Blacklight::Solr
|
|
166
159
|
|
167
160
|
solr_params[:rows] = rows
|
168
161
|
|
169
|
-
|
170
|
-
solr_params[:start] = start
|
171
|
-
end
|
162
|
+
solr_params[:start] = start if start.nonzero?
|
172
163
|
end
|
173
164
|
|
174
165
|
###
|
@@ -258,7 +249,6 @@ module Blacklight::Solr
|
|
258
249
|
end
|
259
250
|
end
|
260
251
|
|
261
|
-
|
262
252
|
##
|
263
253
|
# A helper method used for generating solr LocalParams, put quotes
|
264
254
|
# around the term unless it's a bare-word. Escape internal quotes
|
@@ -271,7 +261,7 @@ module Blacklight::Solr
|
|
271
261
|
val.gsub("'", "\\\\\'").gsub('"', "\\\\\"") +
|
272
262
|
options[:quote]
|
273
263
|
end
|
274
|
-
|
264
|
+
val
|
275
265
|
end
|
276
266
|
|
277
267
|
private
|
@@ -287,28 +277,26 @@ module Blacklight::Solr
|
|
287
277
|
local_params = []
|
288
278
|
local_params << "tag=#{facet_config.tag}" if facet_config and facet_config.tag
|
289
279
|
|
290
|
-
prefix = "{!#{local_params.join(
|
280
|
+
prefix = "{!#{local_params.join(' ')}}" unless local_params.empty?
|
291
281
|
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
facet_config.query[value][:fq]
|
296
|
-
else
|
297
|
-
# exclude all documents if the custom facet key specified was not found
|
298
|
-
'-*:*'
|
299
|
-
end
|
300
|
-
when value.is_a?(Range)
|
301
|
-
"#{prefix}#{solr_field}:[#{value.first} TO #{value.last}]"
|
282
|
+
if facet_config and facet_config.query
|
283
|
+
if facet_config.query[value]
|
284
|
+
facet_config.query[value][:fq]
|
302
285
|
else
|
303
|
-
|
286
|
+
# exclude all documents if the custom facet key specified was not found
|
287
|
+
'-*:*'
|
288
|
+
end
|
289
|
+
elsif value.is_a?(Range)
|
290
|
+
"#{prefix}#{solr_field}:[#{value.first} TO #{value.last}]"
|
291
|
+
else
|
292
|
+
"{!term f=#{solr_field}#{(' ' + local_params.join(' ')) unless local_params.empty?}}#{convert_to_term_value(value)}"
|
304
293
|
end
|
305
294
|
end
|
306
295
|
|
307
296
|
def convert_to_term_value(value)
|
308
|
-
|
309
|
-
when (value.is_a?(DateTime) or value.is_a?(Time))
|
297
|
+
if value.is_a?(DateTime) or value.is_a?(Time)
|
310
298
|
value.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
|
311
|
-
|
299
|
+
elsif value.is_a?(Date)
|
312
300
|
value.to_time(:local).strftime("%Y-%m-%dT%H:%M:%SZ")
|
313
301
|
else
|
314
302
|
value.to_s
|
data/lib/blacklight/utils.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'ostruct'
|
3
3
|
module Blacklight
|
4
|
-
|
5
4
|
module Utils
|
6
5
|
def self.needs_attr_accessible?
|
7
6
|
protected_attributes_enabled?
|
@@ -39,7 +38,7 @@ module Blacklight
|
|
39
38
|
|
40
39
|
##
|
41
40
|
# Merge the values of this OpenStruct with another OpenStruct or Hash
|
42
|
-
# @param [Hash,#to_h]
|
41
|
+
# @param [Hash,#to_h] other_hash
|
43
42
|
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
|
44
43
|
def merge other_hash
|
45
44
|
self.class.new to_h.merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
@@ -47,7 +46,7 @@ module Blacklight
|
|
47
46
|
|
48
47
|
##
|
49
48
|
# Merge the values of another OpenStruct or Hash into this object
|
50
|
-
# @param [Hash,#to_h]
|
49
|
+
# @param [Hash,#to_h] other_hash
|
51
50
|
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
|
52
51
|
def merge! other_hash
|
53
52
|
@table.merge!((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
@@ -58,7 +57,6 @@ module Blacklight
|
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
|
-
|
62
60
|
##
|
63
61
|
# An OpenStruct refinement that converts any hash-keys into
|
64
62
|
# additional instances of NestedOpenStructWithHashAccess
|
@@ -142,7 +140,7 @@ module Blacklight
|
|
142
140
|
|
143
141
|
##
|
144
142
|
# Merge the values of this OpenStruct with another OpenStruct or Hash
|
145
|
-
# @param [Hash,#to_h]
|
143
|
+
# @param [Hash,#to_h] other_hash
|
146
144
|
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
|
147
145
|
def merge other_hash
|
148
146
|
self.class.new nested_class, to_h.merge((other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
@@ -150,7 +148,7 @@ module Blacklight
|
|
150
148
|
|
151
149
|
##
|
152
150
|
# Merge the values of another OpenStruct or Hash into this object
|
153
|
-
# @param [Hash,#to_h]
|
151
|
+
# @param [Hash,#to_h] other_hash
|
154
152
|
# @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
|
155
153
|
def merge! other_hash
|
156
154
|
@table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)
|
@@ -162,15 +160,20 @@ module Blacklight
|
|
162
160
|
def method_missing(mid, *args)
|
163
161
|
len = args.length
|
164
162
|
|
165
|
-
if len
|
163
|
+
if len.zero?
|
166
164
|
new_ostruct_member(mid)
|
167
165
|
@table[mid]
|
168
166
|
else
|
169
167
|
super
|
170
168
|
end
|
171
169
|
end
|
170
|
+
|
171
|
+
def respond_to_missing?(*_)
|
172
|
+
true
|
173
|
+
end
|
172
174
|
|
173
175
|
private
|
176
|
+
|
174
177
|
def set_default_proc!
|
175
178
|
self.default_proc = lambda do |hash, key|
|
176
179
|
hash[key] = self.nested_class.new
|