Using define method instead of class eval when defining model callbacks.
Based on my benchmark results, this change improves performance
substantially when defining callbacks.

This benchmark (https://gist.github.com/wangjohn/5542610) was run using
the current master and also using my experimental branch which replaced
class_eval with define_single_method.

Using class_eval (current master):

                    user     system      total        real
10 trials       0.000000   0.000000   0.000000 (  0.001568)
50 trials       0.020000   0.000000   0.020000 (  0.021715)
500 trials      0.110000   0.000000   0.110000 (  0.115357)
1000 trials     0.250000   0.000000   0.250000 (  0.260025)
10000 trials    2.560000   0.000000   2.560000 (  2.568408)
50000 trials   12.800000   0.010000  12.810000 ( 12.886871)

Using define_single_method (experimental branch):

                    user     system      total        real
10 trials       0.000000   0.000000   0.000000 (  0.000790)
50 trials       0.000000   0.000000   0.000000 (  0.002960)
500 trials      0.050000   0.010000   0.060000 (  0.055690)
1000 trials     0.100000   0.000000   0.100000 (  0.094073)
10000 trials    0.890000   0.000000   0.890000 (  0.900364)
50000 trials    4.650000   0.000000   4.650000 (  4.686127)
we need to indicate the type of callback
polymorphic comparison operator
fix object comparison case
if the callbacks are not the same class, they cannot be duplicates
separate filters from source code
Merge pull request #10524 from wangjohn/define_method_for_callbacks

Using define method instead of class eval when defining model callbacks.
extracted piece of code into a method

In order to fix #10421 I need to enable merge to take an option
so that relations could be merged without making the last where
condition to win.

That fix would forever reside in 4-0-stable branch and would not be
merged to master since using scope without lambda has been deprecated.

In this commit I have extracted code into a method and I think it
makes code look better. Hence the request to merge it in both
master and 4-0-stable.

If there is any concern then this code can be merged only in
4-0-stable and that would be fine too.
separate identification computation
Merge branch 'polycb'

* polycb:
  separate identification computation
  separate filters from source code
  if the callbacks are not the same class, they cannot be duplicates
  fix object comparison case
  polymorphic comparison operator
adding tests for lambdas as conditions
adding a class conditional test
using strings as scopes is not used anywhere, so remove it
add test for object conditional with scope
use public send on the scope parameters
Merge pull request #10523 from neerajdotname/last-where-clause-wins

Extraction to enable fixing #10421