Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
KVO in Ruby
Ruby
Branch: master
Failed to load latest commit information.
lib only fire when the value actually changes; version bump
spec only fire when the value actually changes; version bump
.gitignore added key value binding
Gemfile
README.md
Rakefile
kvo.gemspec initial write

README.md

Description

Key-Value Observing and Binding in ruby

Synopsis

Fires a Publisher event whenever the variable is set.

How do I use it?

    # kvo example 
    class Foo
      include Kvo
      kvo_attr_accessor :bar, :baz
    end

    f = Foo.new
    f.when :bar_changed do |oldVal, newVal|
      puts "bar was changed from #{oldVal} to #{newVal}"
    end


    # kvb example 
    class Baz
      attr_accessor :bar
    end

    b = Bar.new
    # b's bar will be updated whenever f's is
    f.kvo_bind_attr :bar, b

    # optional transforms
    f.kvo_bind_attr :bar, b do |val|
      val + 5
    end

Authors

Something went wrong with that request. Please try again.