From 3d90733e937d11b6905ff11ce006a591ec11b4f4 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 15 Dec 2007 02:27:11 +0000 Subject: Ruby 1.9 compat: prefer builtin String#starts_ and ends_with? if available [chuyeow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8397 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/string/starts_ends_with.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/string') diff --git a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb index 67174019db..3960669798 100644 --- a/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +++ b/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb @@ -3,6 +3,13 @@ module ActiveSupport #:nodoc: module String #:nodoc: # Additional string tests. module StartsEndsWith + def self.included(base) + base.class_eval do + alias_method :start_with?, :starts_with? + alias_method :end_with?, :ends_with? + end + end + # Does the string start with the specified +prefix+? def starts_with?(prefix) prefix = prefix.to_s -- cgit v1.2.3