Simply modify methods that take a block to also provide a proxy
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
README.textile
Rakefile
VERSION.yml
proxy_block.gemspec

README.textile

ProxyBlock

Overview

Simply modify methods that take a block to also provide a proxy

Usage

Example Classes


  class Wrapper

    def hello
      puts 'hello world'
    end

    def wrap(word = 'wrap')
      puts "#{word} start"
      yield
      puts "#{word} end"
    end
    proxy_block :wrap
    
  end

Standard behavior is maintained


  w = Wrapper.new
  w.wrap{ w.hello }
  # => wrap start
  # => hello world
  # => wrap end

Proxy Form


  w = Wrapper.new
  w.wrap.hello
  # => wrap start
  # => hello world
  # => wrap end