app/services/blacklight/field_retriever.rb in blacklight-6.25.0 vs app/services/blacklight/field_retriever.rb in blacklight-7.0.0.rc1

- old
+ new

@@ -7,11 +7,11 @@ @field_config = field_config end attr_reader :document, :field_config delegate :field, to: :field_config - + # @return [Array] def fetch Array.wrap( if field_config.highlight retrieve_highlight @@ -23,35 +23,35 @@ ) end private - def retrieve_simple - # regular document field - if field_config.default and field_config.default.is_a? Proc - document.fetch(field_config.field, &field_config.default) - else - document.fetch(field_config.field, field_config.default) - end + def retrieve_simple + # regular document field + if field_config.default && field_config.default.is_a?(Proc) + document.fetch(field_config.field, &field_config.default) + else + document.fetch(field_config.field, field_config.default) end + end - def retieve_using_accessor - # implicit method call - if field_config.accessor == true - document.send(field) - # arity-1 method call (include the field name in the call) - elsif !field_config.accessor.is_a?(Array) && document.method(field_config.accessor).arity.nonzero? - document.send(field_config.accessor, field) - # chained method calls - else - Array(field_config.accessor).inject(document) do |result, method| - result.send(method) - end + def retieve_using_accessor + # implicit method call + if field_config.accessor == true + document.send(field) + # arity-1 method call (include the field name in the call) + elsif !field_config.accessor.is_a?(Array) && document.method(field_config.accessor).arity.nonzero? + document.send(field_config.accessor, field) + # chained method calls + else + Array(field_config.accessor).inject(document) do |result, method| + result.send(method) end end + end - def retrieve_highlight - # retrieve the document value from the highlighting response - document.highlight_field(field_config.field).map(&:html_safe) if document.has_highlight_field? field_config.field - end + def retrieve_highlight + # retrieve the document value from the highlighting response + document.highlight_field(field_config.field).map(&:html_safe) if document.has_highlight_field? field_config.field + end end end