Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

tappie is an enhanced version of a tap method

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .bundle
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 tappie.gemspec
README.markdown

= 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.

Something went wrong with that request. Please try again.