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
|
# File 'lib/congo/scoper.rb', line 8
def acts_as_congo_scoper
if !self.included_modules.include?(MongoMapper::Document)
class_eval <<-EOV
include Congo::Scoper::InstanceMethods
def scoper_instance
@proxy_scoper ||= Congo::ProxyScoper.find_by_ext_id_and_ext_type(self.id, self.class.name)
if @proxy_scoper.nil?
@proxy_scoper = Congo::ProxyScoper.create!(:ext_type => self.class.name, :ext_id => self.id)
end
@proxy_scoper
end
def content_types
scoper_instance.content_types
end
EOV
else
class_eval <<-EOV
include Congo::Scoper::InstanceMethods
many :content_types, :class_name => 'Congo::ContentType', :as => :scope
def scoper_instance
nil
end
EOV
end
end
|