Skip to content

Commit

Permalink
Avoid using respond_to? on a relation, since it memoizes an arel object
Browse files Browse the repository at this point in the history
  • Loading branch information
shioyama committed May 27, 2017
1 parent fcdf5aa commit d3e9748
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mobility/backend/active_record/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def initialize(attributes, **_)
# @note Only want to define this once, even if multiple QueryMethods
# modules are included, so define it here in extended method
def extended(relation)
unless relation.respond_to?(:mobility_where_chain)
unless relation.methods(false).include?(:mobility_where_chain)
relation.define_singleton_method(:mobility_where_chain) do
@mobility_where_chain ||= Class.new(::ActiveRecord::QueryMethods::WhereChain)
end
Expand Down

0 comments on commit d3e9748

Please sign in to comment.