I want to define method like include?(obj) which check existence of obj in array of my class. Is there a way to do this in ruby?
I have Item class
class Item < ActiveRecord::Base
include Comparable
belongs_to :itemable, :polymorphic => true
def <=>(other)
self.itemable.id <=> other.itemable.id
end
...
end
and I want to use it this way
item_set1.subset? item_set2
but it turns out not using <=> in the process and using only item.id to check. How to override subset or other ways to get this done.
Thanks