rails/rails — pull request #11945 by Mik-die (2013-08-20 11:39:12+00:00)
Title: check class hierarchy with is_a? in PredicateBuilder.expand

This patch replaces using condition `value.class < Base` in favor of `value.is_a?(Base)`

This is not break something in general using in Rails application (because ActiveRecord::Base is an abstract class and can not be instantiated), but makes convenient using decorator pattern.

For example [Draper gem](https://github.com/drapergem/draper) redefine [`#is_a?`](https://github.com/drapergem/draper/blob/master/lib/draper/decorator.rb#L179-L182) method to check against decorated class.

So this patch makes it possible to use

```ruby
Comment.where(commentable: post.decorate)
# just like `Comment.where(commentable: post)`
```

instead of

```ruby
decorated_post = post.decorate
Comment.where(commentable_id: decorated_post.id, commentable_type: decorated_post.class.base_class.to_s)
```