lib/garcon/task/copy_on_notify_observer_set.rb
# Adds an observer to this set. If a block is passed, the observer will be
# created by this method and no other params should be passed
#
# @param [Object] observer
#   The observer to add
#
# @param [Symbol] func
#   The function to call on the observer during notification. The default
#   is :update
#
# @return [Object]
#   the added observer
Adds an observer to this set. If a block is passed, the observer will be
created by this method and no other params should be passed
Adds an observer to this set . If a block is passed the observer will be created by this method and no other params should be passed
def add_observer(observer = nil, func = :update, &block)
      if observer.nil? && block.nil?
        raise ArgumentError, 'should pass observer as a first argument or block'
      elsif observer && block
        raise ArgumentError.new('cannot provide both an observer and a block')
      end
      if block
        observer = block
        func = :call
      end
      begin
        @mutex.lock
        @observers[observer] = func
      ensure
        @mutex.unlock
      end
      observer
    end
def add_observer ( observer = nil , func = :update , & block ) if observer . nil? && block . nil? raise ArgumentError , 'should pass observer as a first argument or block' elsif observer && block raise ArgumentError . new ( 'cannot provide both an observer and a block' ) end if block observer = block func = :call end begin @mutex . lock @observers [ observer ] = func ensure @mutex . unlock end observer end
Adds an observer to this set.
Adds an observer to this set .
the added observer
the added observer
Object
observer
<not_specific>
func
<not_specific>
block
<not_specific>
<not_specific>
func The function to call on the observer during notification. The default is :update
func The function to call on the observer during notification . The default is : update