Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created January 21, 2010 15:37
Show Gist options
  • Save jhsu/282884 to your computer and use it in GitHub Desktop.
Save jhsu/282884 to your computer and use it in GitHub Desktop.
def run(command=:all)
query = {}
options = {:include => self.tables, :conditions => self.to_condition}
options.merge!({:select => :id}) if command == :count
query[:id_in] = ids if ids && !ids.empty?
query[:id_not_in] = exclude_ids if exclude_ids && !exclude_ids.empty?
results = Applicant.search
if !query.keys.empty?
query.each { |scope, ids| results = results.send(scope, ids) }
results = results.all
else
results = []
end
results = (results + Applicant.all(*options)).uniq if self.to_condition
command == :count ? results.count : results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment