This relies upon a Ruby 1.9 extension that can be done in 1.8 by including the following:
class Symbol
def to_proc
proc { |obj, *args| obj.send(self, *args) }
end
end
I believe Rails defines this in ActiveSupport
.
More Related Contents:
- Regex for reverse match a string
- How to write a switch statement in Ruby
- Ruby, Difference between exec, system and %x() or Backticks
- What is the difference or value of these block coding styles in Ruby?
- How to understand symbols in Ruby
- Look up all descendants of a class in Ruby
- What does &. (ampersand dot) mean in Ruby?
- “for” vs “each” in Ruby
- Mixing keyword with regular arguments in Ruby?
- String concatenation vs. interpolation in Ruby
- ActionController::UnknownFormat
- Sort hash by key, return hash in Ruby
- How to merge Ruby hashes
- I don’t understand ruby local scope
- Weird backslash substitution in Ruby
- Strange \n in base64 encoded string in Ruby
- Printing the source code of a Ruby block
- Double Pipe Symbols in Ruby Variable Assignment? [duplicate]
- Why does Ruby’s ‘gets’ includes the closing newline?
- Error to install Nokogiri on OSX 10.9 Maverick?
- How do I avoid trailing empty items being removed when splitting strings?
- How do I test a function with gets.chomp in it?
- Why does “compass watch” say it cannot load sass/script/node (LoadError)?
- When to use `require`, `load` or `autoload` in Ruby?
- Natural Language Processing in Ruby [closed]
- How can I get the absolute URL when extracting links using Nokogiri?
- How to determine if a character is a Chinese character
- How to turn a string into a method call? [duplicate]
- What is the behavior when using both positional and keyword arguments in Ruby?
- Should I use alias or alias_method?