diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-04-11 00:52:42 +0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-04-11 03:17:09 +0800 |
commit | a9f3c9da01d721963d05949604ead909aaabbf36 (patch) | |
tree | 5e278655997e1dcf86d9e0ee2f6be30d323fc8b4 /railties/guides/rails_guides | |
parent | 635d991683c439da56fa72853880e88e6ac291ed (diff) | |
download | rails-a9f3c9da01d721963d05949604ead909aaabbf36.tar.gz rails-a9f3c9da01d721963d05949604ead909aaabbf36.tar.bz2 rails-a9f3c9da01d721963d05949604ead909aaabbf36.zip |
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?.
Diffstat (limited to 'railties/guides/rails_guides')
-rw-r--r-- | railties/guides/rails_guides/textile_extensions.rb | 6 |
1 files changed, 4 insertions, 2 deletions
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 = "<div class='#{css_class}'><p>" result << $2.strip @@ -33,7 +35,7 @@ module RailsGuides def code(body) body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m| es = ERB::Util.h($2) - css_class = ['erb', 'shell'].include?($1) ? 'html' : $1 + css_class = $1.either?('erb', 'shell') ? 'html' : $1 %{<notextile><div class="code_container"><code class="#{css_class}">#{es}</code></div></notextile>} end end |