Skip to content

Commit

Permalink
Blacklist Blacklight::Document#empty? to avoid ActiveModel deprecatio…
Browse files Browse the repository at this point in the history
…n on validation
  • Loading branch information
jcoyne committed Aug 30, 2017
1 parent 41fb6aa commit e1b99cb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app/models/concerns/blacklight/document.rb
Expand Up @@ -37,7 +37,7 @@ module Blacklight::Document
extend ActiveModel::Naming
include Blacklight::Document::Extensions
include GlobalID::Identification
end
end

attr_reader :response, :_source
alias_method :solr_response, :response
Expand Down Expand Up @@ -69,15 +69,14 @@ def method_missing(m, *args, &b)
end

def respond_to_missing? m, *args
return super if m == :to_hash

return super if %i(empty? to_hash).include?(m)
_source_responds_to?(m, *args) || super
end

# Helper method to check if value/multi-values exist for a given key.
# The value can be a string, or a RegExp
# Multiple "values" can be given; only one needs to match.
#
#
# Example:
# doc.has?(:location_facet)
# doc.has?(:location_facet, 'Clemons')
Expand Down Expand Up @@ -141,12 +140,12 @@ def more_like_this
module ClassMethods
attr_writer :unique_key
def unique_key
@unique_key ||= 'id'
@unique_key ||= 'id'
end
end

private

def _source_responds_to? *args
_source && self != _source && _source.respond_to?(*args)
end
Expand Down

0 comments on commit e1b99cb

Please sign in to comment.