environment_finder.rb
985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class EnvironmentFinder
def initialize env
@environment = env
end
def articles(query='*', options = {})
@environment.articles.find_by_contents(query, {}, options)
end
def people(query='*', options = {})
@environment.people.find_by_contents(query, {}, options)
end
def communities(query='*', options = {})
@environment.communities.find_by_contents(query, {}, options)
end
def products(query='*', options = {})
@environment.products.find_by_contents(query, {}, options)
end
def enterprises(query='*', options = {})
@environment.enterprises.find_by_contents(query, {}, options)
end
def comments(query='*', options = {})
@environment.comments.find_by_contents(query, {}, options)
end
def recent(asset, limit = 10)
with_options :limit => limit, :order => 'created_at desc, id desc' do |finder|
finder.send(asset, '*', {})
end
end
def count(asset)
@environment.send(asset).count
end
end