Created
September 23, 2009 00:32
-
-
Save chendo/191582 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Symbol#to_proc is already defined in Rails | |
class Symbol | |
def to_proc | |
Proc.new { |item| item.send self } | |
end | |
end | |
class Array | |
def to_proc | |
Proc.new do |item| | |
inject(item) do |mem, obj| | |
mem.send(obj) | |
end | |
end | |
end | |
end | |
p ["ID", "TITLE"].collect(&[:downcase, :to_sym]) # => [:id, :title] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment