mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #3229 from amatsuda/string_prepend
ruby193: String#prepend
This commit is contained in:
@@ -75,7 +75,7 @@ end
|
||||
|
||||
module ActiveSupport #:nodoc:
|
||||
class SafeBuffer < String
|
||||
UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase"].freeze
|
||||
UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase", "prepend"].freeze
|
||||
|
||||
alias_method :original_concat, :concat
|
||||
private :original_concat
|
||||
@@ -142,16 +142,18 @@ module ActiveSupport #:nodoc:
|
||||
end
|
||||
|
||||
UNSAFE_STRING_METHODS.each do |unsafe_method|
|
||||
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
||||
def #{unsafe_method}(*args, &block) # def capitalize(*args, &block)
|
||||
to_str.#{unsafe_method}(*args, &block) # to_str.capitalize(*args, &block)
|
||||
end # end
|
||||
if 'String'.respond_to?(unsafe_method)
|
||||
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
||||
def #{unsafe_method}(*args, &block) # def capitalize(*args, &block)
|
||||
to_str.#{unsafe_method}(*args, &block) # to_str.capitalize(*args, &block)
|
||||
end # end
|
||||
|
||||
def #{unsafe_method}!(*args) # def capitalize!(*args)
|
||||
@dirty = true # @dirty = true
|
||||
super # super
|
||||
end # end
|
||||
EOT
|
||||
def #{unsafe_method}!(*args) # def capitalize!(*args)
|
||||
@dirty = true # @dirty = true
|
||||
super # super
|
||||
end # end
|
||||
EOT
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
Reference in New Issue
Block a user