aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2008-02-07 21:09:23 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2008-02-07 21:09:23 +0000
commitfbd7ec3c9f0b1a5327ead66e0ac11b1d1d509f70 (patch)
tree44a1b9f1edd73c882aafd3d4a9f168a54963a6e9 /activesupport/lib/active_support/core_ext
parent4a9fc4424ff7402326bf17c8bfd89bf6cbc42c8c (diff)
downloadrails-fbd7ec3c9f0b1a5327ead66e0ac11b1d1d509f70.tar.gz
rails-fbd7ec3c9f0b1a5327ead66e0ac11b1d1d509f70.tar.bz2
rails-fbd7ec3c9f0b1a5327ead66e0ac11b1d1d509f70.zip
Added Base64.encode64s to encode values in base64 without the newlines. This makes the values immediately usable as URL parameters or memcache keys without further processing [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8816 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/base64.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/base64/encoding.rb13
2 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/base64.rb b/activesupport/lib/active_support/core_ext/base64.rb
new file mode 100644
index 0000000000..d8b1813851
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/base64.rb
@@ -0,0 +1,7 @@
+require 'base64'
+
+require 'active_support/core_ext/base64/encoding'
+
+module Base64#:nodoc:
+ extend ActiveSupport::CoreExtensions::Base64::Encoding
+end
diff --git a/activesupport/lib/active_support/core_ext/base64/encoding.rb b/activesupport/lib/active_support/core_ext/base64/encoding.rb
new file mode 100644
index 0000000000..19671992d2
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/base64/encoding.rb
@@ -0,0 +1,13 @@
+module ActiveSupport #:nodoc:
+ module CoreExtensions #:nodoc:
+ module Base64 #:nodoc:
+ module Encoding
+ # Encodes the value as base64 without the newline breaks. This makes the base64 encoding readily usable as URL parameters
+ # or memcache keys without further processing.
+ def encode64s(value)
+ ::Base64.encode64(value).gsub(/\n/, '')
+ end
+ end
+ end
+ end
+end \ No newline at end of file