Module: DataMapper::Observer::ClassMethods

Defined in:
lib/dm-observer/observer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#observingObject

Returns the value of attribute observing.



15
16
17
# File 'lib/dm-observer/observer.rb', line 15

def observing
  @observing
end

Instance Method Details

#after(sym, &block) ⇒ Object



33
34
35
36
37
# File 'lib/dm-observer/observer.rb', line 33

def after(sym, &block)
  self.observing.each do |klass|
    klass.after(sym.to_sym, &block)
  end
end

#after_class_method(sym, &block) ⇒ Object



45
46
47
48
49
# File 'lib/dm-observer/observer.rb', line 45

def after_class_method(sym, &block)
  self.observing.each do |klass|
    klass.after_class_method(sym.to_sym, &block)
  end
end

#before(sym, &block) ⇒ Object



27
28
29
30
31
# File 'lib/dm-observer/observer.rb', line 27

def before(sym, &block)
  self.observing.each do |klass|
    klass.before(sym.to_sym, &block)
  end
end

#before_class_method(sym, &block) ⇒ Object



39
40
41
42
43
# File 'lib/dm-observer/observer.rb', line 39

def before_class_method(sym, &block)
  self.observing.each do |klass|
    klass.before_class_method(sym.to_sym, &block)
  end
end

#initializeObject



17
18
19
# File 'lib/dm-observer/observer.rb', line 17

def initialize
  self.observing = []
end

#observe(*args) ⇒ Object

Assign an Array of Class names to watch.

observe User, Article, Topic


23
24
25
# File 'lib/dm-observer/observer.rb', line 23

def observe(*args)
  self.observing = args
end