aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-20 17:10:10 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-20 18:12:44 -0700
commit3694227f24d0f220c0ce7ef6c7f51598e2715d2d (patch)
treed9f68a8e73b0d7d105bc0549c3cc4fea0595daf5 /activesupport
parent68398838544a778244e6028f2c30deb7313ea0b2 (diff)
downloadrails-3694227f24d0f220c0ce7ef6c7f51598e2715d2d.tar.gz
rails-3694227f24d0f220c0ce7ef6c7f51598e2715d2d.tar.bz2
rails-3694227f24d0f220c0ce7ef6c7f51598e2715d2d.zip
Break out Symbol#to_proc as a future-ruby extension
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/symbol.rb15
-rw-r--r--activesupport/lib/active_support/core_ext/symbol/to_proc.rb14
2 files changed, 15 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/core_ext/symbol.rb b/activesupport/lib/active_support/core_ext/symbol.rb
index 520369452b..c103cd9dcf 100644
--- a/activesupport/lib/active_support/core_ext/symbol.rb
+++ b/activesupport/lib/active_support/core_ext/symbol.rb
@@ -1,14 +1 @@
-class Symbol
- # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
- #
- # # The same as people.collect { |p| p.name }
- # people.collect(&:name)
- #
- # # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
- # people.select(&:manager?).collect(&:salary)
- #
- # This is a builtin method in Ruby 1.8.7 and later.
- def to_proc
- Proc.new { |*args| args.shift.__send__(self, *args) }
- end unless :to_proc.respond_to?(:to_proc)
-end
+require 'active_support/core_ext/symbol/to_proc'
diff --git a/activesupport/lib/active_support/core_ext/symbol/to_proc.rb b/activesupport/lib/active_support/core_ext/symbol/to_proc.rb
new file mode 100644
index 0000000000..520369452b
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/symbol/to_proc.rb
@@ -0,0 +1,14 @@
+class Symbol
+ # Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:
+ #
+ # # The same as people.collect { |p| p.name }
+ # people.collect(&:name)
+ #
+ # # The same as people.select { |p| p.manager? }.collect { |p| p.salary }
+ # people.select(&:manager?).collect(&:salary)
+ #
+ # This is a builtin method in Ruby 1.8.7 and later.
+ def to_proc
+ Proc.new { |*args| args.shift.__send__(self, *args) }
+ end unless :to_proc.respond_to?(:to_proc)
+end