Skip to content

Instantly share code, notes, and snippets.

@chendo
Created September 23, 2009 00:32
Show Gist options
  • Save chendo/191582 to your computer and use it in GitHub Desktop.
Save chendo/191582 to your computer and use it in GitHub Desktop.
# 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