Class: RubyMVC::Toolkit::ObserverList

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_mvc/toolkit/notification.rb

Instance Method Summary collapse

Constructor Details

#initializeObserverList

Returns a new instance of ObserverList.



63
64
65
# File 'lib/ruby_mvc/toolkit/notification.rb', line 63

def initialize
  @observers = {}
end

Instance Method Details

#<<(val) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/ruby_mvc/toolkit/notification.rb', line 67

def <<(val)
  if !val.is_a? ObserverReference
    raise ArgumentError, "can only have observer references in the list!"
  end

  @observers[val.observer] = val if !@observers.include? val.observer
end

#delete(val) ⇒ Object



75
76
77
# File 'lib/ruby_mvc/toolkit/notification.rb', line 75

def delete(val)
  @observers.delete(val)
end

#each(&block) ⇒ Object



79
80
81
# File 'lib/ruby_mvc/toolkit/notification.rb', line 79

def each(&block)
  @observers.each_value(&block)
end