Simple extension for deferring method calls.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.rbenv-gemsets
.rbenv-version
Gemfile
LICENSE
README.rdoc
Rakefile
VERSION
deferrable.gemspec

README.rdoc

Deferrable

Deferrable provides a simple way to defer execution of a block without starting another process or thread.

Usage:

class Foo
  include Deferrable

  def bar(opts = {})
    deferred do
      # do something later
    end

    now_and_later do
      # do something now and when deferred blocks are executed
      # this could be useful for cache invalidations... yum
    end
  end

  def later
    complete_deferred # executes all deferred blocks in order
  end

  def nevermind
    clear_deferred # don't execute the deferred blocks after all
  end
end

Install:

gem install deferrable

License:

Copyright © 2009 Justin Balthrop, Geni.com; Published under The MIT License, see LICENSE