Module: DataMapper::Observer::ClassMethods

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#observingObject

Returns the value of attribute observing.



13
14
15
# File 'lib/gems/dm-observer-0.9.9/lib/dm-observer.rb', line 13

def observing
  @observing
end

Instance Method Details

#after(sym, &block) ⇒ Object



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

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

#after_class_method(sym, &block) ⇒ Object



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

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



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

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

#before_class_method(sym, &block) ⇒ Object



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

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

#initializeObject



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

def initialize
  self.observing = []
end

#observe(*args) ⇒ Object

Assign an Array of Class names to watch.

observe User, Article, Topic


21
22
23
24
# File 'lib/gems/dm-observer-0.9.9/lib/dm-observer.rb', line 21

def observe(*args)
  # puts "#{self.to_s} observing... #{args.collect{|c| Extlib::Inflection.classify(c.to_s)}.join(', ')}"
  self.observing = args
end