Sha256: 2403e35d61057e4ac663dbbaf677b61c9c39816b686e1ad0bacd58485014c02f

Contents?: true

Size: 671 Bytes

Versions: 15

Compression:

Stored size: 671 Bytes

Contents

module RubyExt
	module Observable								
		def add_observer observer
			@observable_observers ||= []
			@observable_observers << observer unless @observable_observers.include? observer			
		end
		
		def notify_observers method, *args
			method.should! :be_a, Symbol
			@observable_observers.each{|observer| observer.respond_to method, *args} if @observable_observers			
		end
		
		def delete_observer observer
			@observable_observers.delete observer if @observable_observers
		end
		
		def delete_observers			
			@observable_observers.clear if @observable_observers
		end
		
		def observers_count
			@observable_observers ? @observable_observers.size : 0
		end
	end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
ruby-ext-0.2.16 old/lib/RubyExt/observable.rb
ruby-ext-0.2.15 old/lib/RubyExt/observable.rb
ruby-ext-0.2.13 old/lib/RubyExt/observable.rb
ruby-ext-0.2.12 old/lib/RubyExt/observable.rb
ruby-ext-0.2.11 old/lib/RubyExt/observable.rb
ruby-ext-0.2.10 old/lib/RubyExt/observable.rb
ruby-ext-0.2.9 old/lib/RubyExt/observable.rb
ruby-ext-0.2.8 old/lib/RubyExt/observable.rb
ruby-ext-0.2.7 old/lib/RubyExt/observable.rb
ruby-ext-0.2.6 old/lib/RubyExt/observable.rb
ruby-ext-0.2.5 old/lib/RubyExt/observable.rb
ruby-ext-0.2.4 old/lib/RubyExt/observable.rb
ruby-ext-0.2.3 old/lib/RubyExt/observable.rb
RubyExt-0.1.1 lib/RubyExt/observable.rb
RubyExt-0.1.2 lib/RubyExt/observable.rb