Class: Hash
Constant Summary collapse
- @@listeners =
{}
Instance Attribute Summary collapse
-
#hash_reads ⇒ Object
readonly
Returns the value of attribute hash_reads.
-
#hash_writes ⇒ Object
readonly
Returns the value of attribute hash_writes.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#hash_reads ⇒ Object (readonly)
Returns the value of attribute hash_reads.
3 4 5 |
# File 'lib/stratagem/extensions/hash.rb', line 3 def hash_reads @hash_reads end |
#hash_writes ⇒ Object (readonly)
Returns the value of attribute hash_writes.
3 4 5 |
# File 'lib/stratagem/extensions/hash.rb', line 3 def hash_writes @hash_writes end |
Class Method Details
.track_parameter_reads(&block) ⇒ Object
15 16 17 18 19 |
# File 'lib/stratagem/extensions/hash.rb', line 15 def self.track_parameter_reads(&block) @@listeners[block] = [] yield @@listeners.delete(block) end |
Instance Method Details
#[](name) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/stratagem/extensions/hash.rb', line 7 def [](name) if (@auditing) @@listeners.values.each {|listener| listener << name } (@hash_reads ||= []) << name end ruby_get name end |
#enable_auditing ⇒ Object
21 22 23 |
# File 'lib/stratagem/extensions/hash.rb', line 21 def enable_auditing @auditing = true end |
#ruby_get ⇒ Object
2 |
# File 'lib/stratagem/extensions/hash.rb', line 2 alias_method :ruby_get, :[] |