Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Defines Kernel#its and Kernel#it that queue and defer method calls, simplifying list comprehension and case statements.
Ruby
tag: v1.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.document
.gitignore
.rspec
Gemfile
LICENSE.txt
README.rdoc
Rakefile
its-it.gemspec

README.rdoc

its-it

Overview

This gem defines kernel methods its and it that extend the Symbol#to_proc idiom to support chaining multiple methods.

The pure Ruby way to chain methods when enumerating a list would be:

users.collect{|user| user.contact}.collect{|contact| contact.last_name}.collect{|name| name.capitalize}

Using Symbol#to_proc, this becomes simpler:

users.collect(&:contact).collect(&:last_name).collect(&:capitalize)

And using its, this becomes becomes simpler still:

users.collect(&its.contact.last_name.capitalize)

it is an alias for its, to use with methods that describe actions rather than posessives. For example:

items.collect(&it.to_s.capitalize)

Installation

Install from rubygems.org via

$ gem install "its-it"

or in a Gemfile

gem "its-it"

Compatibility

Tested with ruby 1.8.7 and ruby 1.9.2

History

This gem is a clone of Jay Philips' methodphitamine gem, updated to be compatible with ruby 1.9.2 and gemspec, renamed its-it, and installed on rubygems.org. Unlike methodphitamine, this gem includes only its and it, not the “maybe” monad.

Something went wrong with that request. Please try again.