Skip to content

Commit

Permalink
memoized search_indexable_hash in instance_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
masukomi committed Jul 16, 2024
1 parent 14f7a18 commit bb66b8f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/search/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def searchable_attributes
# _unless_ one is already defined. This gem relies on "object_class" being present
# in returned results
def search_indexable_hash
return @_search_indexable_hash if defined?(@_search_indexable_hash)
klass = self.class
# the to_s & to_sym is just safety in case someone
# defined searchable_attributes as an array of strings
Expand All @@ -83,7 +84,7 @@ def search_indexable_hash

hash["object_class"] = klass.name unless hash.has_key?("object_class")
hash["original_document_id"] = _id.to_s if klass.has_class_prefixed_search_ids?
hash
@_search_indexable_hash = hash
end

# A convenience method to ease accessing the administratable index
Expand Down

0 comments on commit bb66b8f

Please sign in to comment.