From a9f3c9da01d721963d05949604ead909aaabbf36 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Mon, 11 Apr 2011 00:52:42 +0800 Subject: Using Object#in? and Object#either? in various places There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?. --- railties/guides/rails_guides/textile_extensions.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/rails_guides/textile_extensions.rb b/railties/guides/rails_guides/textile_extensions.rb index affef1ccb0..f1486a7c10 100644 --- a/railties/guides/rails_guides/textile_extensions.rb +++ b/railties/guides/rails_guides/textile_extensions.rb @@ -1,9 +1,11 @@ +require 'active_support/core_ext/object/inclusion' + module RailsGuides module TextileExtensions def notestuff(body) body.gsub!(/^(IMPORTANT|CAUTION|WARNING|NOTE|INFO)[.:](.*)$/) do |m| css_class = $1.downcase - css_class = 'warning' if ['caution', 'important'].include?(css_class) + css_class = 'warning' if css_class.either?('caution', 'important') result = "

" result << $2.strip @@ -33,7 +35,7 @@ module RailsGuides def code(body) body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)}m) do |m| es = ERB::Util.h($2) - css_class = ['erb', 'shell'].include?($1) ? 'html' : $1 + css_class = $1.either?('erb', 'shell') ? 'html' : $1 %{

#{es}
} end end -- cgit v1.2.3