blob: 3729b3435efa1529653bf5597ad1d0aed879d3f8 (
plain) (
blame)
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
|
class ORM
include ActiveModel::Observing
def save
notify_observers :before_save
end
class Observer < ActiveModel::Observer
def before_save_invocations
@before_save_invocations ||= []
end
def before_save(record)
before_save_invocations << record
end
end
end
class Widget < ORM; end
class Budget < ORM; end
class WidgetObserver < ORM::Observer; end
class BudgetObserver < ORM::Observer; end
class AuditTrail < ORM::Observer
observe :widget, :budget
end
ORM.instantiate_observers
|