= tappie

Tappie goes a "long" way in improving Ruby's tap method, which is similar to Rail's returning method.

It allows you to remove the syntax noise from that extra variable:

puts "Guilherme Silveira".tap { puts size }
# 18
# Guilherme Silveira

Scope

Because the invocation scope is the object itself, accessing instance variables result in internal access to the object, not the object scope where the method tap was invoked: this can be what you desire or not. If you want to access the old scope, use tap as it was used before:

@old_scope = 10
puts "Guilherme Silveira".tap { |s| puts s.size; puts @old_scope }

Benefits

Less noise if you are not using @variables of the current scope.
Less code.

Compatibility issues

Because tappie checks the Proc arity, it is fully compatible.

How to use configure it?

Either copy tappie.rb code to your project or gem install it:

gem install tappie

Have fun!

== Team

Guilherme Silveira - Caelum

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

Copyright (c) 2010 guilherme silveira. See LICENSE for details.