36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/activity_stream.rb', line 36
def log_activities(*args, &block)
args = [:create, :update, :destroy] if args.length == 0
activity_triggers = self.activity_triggers
callback = block_given?? block : true
args.each { |verb| activity_triggers["after_#{verb}".intern] = callback }
write_inheritable_attribute :activity_triggers, activity_triggers
unless defined? @_activity_observed
has_many :activities, :as => :object do
def all(options = {})
klass = proxy_owner.klass
Scope.new scope_for_reflection(:find => {:conditions => ['object_type = ? OR indirect_object_type = ?', klass.name, klass.name]}), :find => options
end
def indirectly(options = {})
klass = proxy_owner.klass
Scope.new scope_for_reflection(:find => {:conditions => {:indirect_object_type => klass.name}}), :find => options
end
def directly(options = {})
klass = proxy_owner.klass
Scope.new scope_for_reflection(:find => {:conditions => {:object_type => klass.name}}), :find => options
end
private
def scope_for_reflection(options)
Scope.new proxy_reflection.klass, options
end
end
add_observer ActivityObserver.instance
@_activity_observed = true
end
end
|