Sha256: 71774970de911c539c96c6a81d4de79d54dc3ca47b946da1854fc1da16980708

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'observer'

class MonitoredHash < Hash
  include Observable
  
  alias :nontainting_assign :[]=
  def []=(key, value)
    nontainting_assign(key, value)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_delete :delete
  def delete(key, &block)
    nontainting_delete(key, &block)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_shift :shift
  def shift
    nontainting_shift
    changed
    notify_observers(self)
  end
  
  alias :nontainting_reject! :reject!
  def reject!(&block)
    nontainting_reject!(&block)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_clear :clear
  def clear
    nontainting_clear
    changed
    notify_observers(self)
  end
  
  alias :nontainting_merge! :merge!
  def merge!(hsh)
    nontainting_merge!(hsh)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_replace :replace
  def replace(hsh)
    nontainting_replace(hsh)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_store :store
  def store(key, value)
    nontainting_store(key, value)
    changed
    notify_observers(self)
  end
  
  alias :nontainting_update :update
  def update(hsh)
    nontainting_update(hsh)
    changed
    notify_observers(self)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
davidrichards-repositories-0.0.3 lib/repositories/monitored_hash.rb
davidrichards-repositories-0.0.4 lib/repositories/monitored_hash.rb
davidrichards-repositories-0.0.5 lib/repositories/monitored_hash.rb
davidrichards-repositories-0.0.6 lib/repositories/monitored_hash.rb