Sha256: 33a376384af1d536a2294bc2f67852a640655194d39d51a33668762584eca107
Contents?: true
Size: 766 Bytes
Versions: 12
Compression:
Stored size: 766 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Observable #:nodoc: extend ActiveSupport::Concern included do attr_reader :observers end # Add an observer to this object. This mimics the standard Ruby observable # library. # # Example: # # <tt>address.add_observer(person)</tt> def add_observer(object) @observers ||= [] @observers.push(object) end # Notify all the objects observing this object of an update. All observers # need to respond to the update method in order to handle this. # # Example: # # <tt>document.notify_observers(self)</tt> def notify_observers(*args) @observers.dup.each { |observer| observer.observe(*args) } if @observers end end end
Version data entries
12 entries across 12 versions & 6 rubygems