Class: MongoMapper::Observer
- Includes:
- Singleton
- Defined in:
- lib/mongo_mapper/observing.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Observer
constructor
A new instance of Observer.
-
#update(observed_method, object) ⇒ Object
:nodoc:.
Constructor Details
Class Method Details
.observe(*models) ⇒ Object
18 19 20 21 22 |
# File 'lib/mongo_mapper/observing.rb', line 18 def observe(*models) models.flatten! models.collect! { |model| model.is_a?(Symbol) ? model.to_s.camelize.constantize : model } define_method(:observed_classes) { Set.new(models) } end |
.observed_class ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mongo_mapper/observing.rb', line 24 def observed_class if observed_class_name = name[/(.*)Observer/, 1] observed_class_name.constantize else nil end end |
Instance Method Details
#update(observed_method, object) ⇒ Object
:nodoc:
37 38 39 |
# File 'lib/mongo_mapper/observing.rb', line 37 def update(observed_method, object) #:nodoc: send(observed_method, object) if respond_to?(observed_method) end |