Skip to content

Commit

Permalink
Symbol responds_to :upcase & :downcase in Ruby >= 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Jun 6, 2012
1 parent edee2c7 commit 0996396
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions actionpack/lib/abstract_controller/collector.rb
Expand Up @@ -4,7 +4,7 @@ module AbstractController
module Collector
def self.generate_method_for_mime(mime)
sym = mime.is_a?(Symbol) ? mime : mime.to_sym
const = sym.to_s.upcase
const = sym.upcase
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{sym}(*args, &block) # def html(*args, &block)
custom(Mime::#{const}, *args, &block) # custom(Mime::HTML, *args, &block)
Expand All @@ -19,7 +19,7 @@ def #{sym}(*args, &block) # def html(*args, &block)
protected

def method_missing(symbol, &block)
mime_constant = Mime.const_get(symbol.to_s.upcase)
mime_constant = Mime.const_get(symbol.upcase)

if Mime::SET.include?(mime_constant)
AbstractController::Collector.generate_method_for_mime(mime_constant)
Expand All @@ -29,4 +29,4 @@ def method_missing(symbol, &block)
end
end
end
end
end
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/caching/pages.rb
Expand Up @@ -110,7 +110,7 @@ def caches_page(*actions)
gzip_level = options.fetch(:gzip, page_cache_compression)
gzip_level = case gzip_level
when Symbol
Zlib.const_get(gzip_level.to_s.upcase)
Zlib.const_get(gzip_level.upcase)
when Fixnum
gzip_level
when false
Expand Down
Expand Up @@ -548,7 +548,7 @@ def add_index_sort_order(option_strings, column_names, options = {})
if options.is_a?(Hash) && order = options[:order]
case order
when Hash
column_names.each {|name| option_strings[name] += " #{order[name].to_s.upcase}" if order.has_key?(name)}
column_names.each {|name| option_strings[name] += " #{order[name].upcase}" if order.has_key?(name)}
when String
column_names.each {|name| option_strings[name] += " #{order.upcase}"}
end
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/log_subscriber.rb
Expand Up @@ -114,7 +114,7 @@ def #{level}(progname = nil, &block)
#
def color(text, color, bold=false)
return text unless colorize_logging
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
color = self.class.const_get(color.upcase) if color.is_a?(Symbol)
bold = bold ? BOLD : ""
"#{bold}#{color}#{text}#{CLEAR}"
end
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/xml_mini.rb
Expand Up @@ -83,7 +83,7 @@ def backend=(name)
if name.is_a?(Module)
@backend = name
else
require "active_support/xml_mini/#{name.to_s.downcase}"
require "active_support/xml_mini/#{name.downcase}"
@backend = ActiveSupport.const_get("XmlMini_#{name}")
end
end
Expand Down

0 comments on commit 0996396

Please sign in to comment.