Module: Kvo::ClassMethods
- Defined in:
- lib/kvo.rb
Instance Method Summary collapse
Instance Method Details
#kvo_attr_accessor(*kvo_symbols) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/kvo.rb', line 4 def kvo_attr_accessor(*kvo_symbols) kvo_symbols.each do |kvo| class_eval <<-METHODS can_fire :#{kvo}_changed unless published_events == :any_event_is_ok def #{kvo} @kvo_#{kvo} end def #{kvo}=(new_val) old = @kvo_#{kvo} unless old == new_val @kvo_#{kvo}=new_val fire :#{kvo}_changed, old, new_val end end METHODS end end |