Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

KVO in Ruby

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 kvo.gemspec
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.