Skip to content

Instantly share code, notes, and snippets.

@dmichael
Created May 27, 2009 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmichael/118773 to your computer and use it in GitHub Desktop.
Save dmichael/118773 to your computer and use it in GitHub Desktop.
module SetNotationHelper
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Here's our little magic hook
def inherited(subclass)
subclass.class_eval do
named_scope :in_set, lambda{|*args|
{ :conditions => "#{table_name}.id IN (#{ parse_set(args.first).to_a.join(',') })" }
}
end
end
end
end
ActiveRecord::Base.send :include, SetNotationHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment