rosa-build/app/models/search.rb

25 lines
580 B
Ruby
Raw Normal View History

2012-11-21 15:04:41 +00:00
class Search
TYPES = ['projects', 'users', 'groups', 'platforms']
def self.by_term_and_type(term, type, paginate_params)
results = {}
case type
when 'all'
TYPES.each{ |t| results[t] = find_collection(t, term, paginate_params) }
when *TYPES
results[type] = find_collection(type, term, paginate_params)
end
results
end
class << self
protected
def find_collection(type, term, paginate_params)
type.classify.constantize.opened.
search(term).
search_order.
paginate(paginate_params)
end
end
end