class Woyo::Attributes::AttributesHash
Attributes
listeners[R]
Public Class Methods
new()
click to toggle source
# File lib/woyo/world/attributes.rb, line 18 def initialize @listeners = {} end
Public Instance Methods
[]=(attr, value)
click to toggle source
Calls superclass method
# File lib/woyo/world/attributes.rb, line 27 def []= attr, value old_value = self[attr] super if value != old_value @listeners[attr].each { |listener| listener.notify attr, value } if @listeners[attr] # attribute listeners (groups, etc..) @listeners[:*].each { |listener| listener.notify attr, value } if @listeners[:*] # wildcard listeners (trackers) end end
Also aliased as: set
add_listener(attr, listener)
click to toggle source
# File lib/woyo/world/attributes.rb, line 22 def add_listener attr, listener @listeners[attr] ||= [] @listeners[attr] << listener end