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?. --- activesupport/lib/active_support/cache/file_store.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/cache/file_store.rb') diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 18182bbb40..5eeb17efd5 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/file/atomic' require 'active_support/core_ext/string/conversions' +require 'active_support/core_ext/object/inclusion' require 'rack/utils' module ActiveSupport @@ -20,7 +21,7 @@ module ActiveSupport end def clear(options = nil) - root_dirs = Dir.entries(cache_path).reject{|f| ['.', '..'].include?(f)} + root_dirs = Dir.entries(cache_path).reject{|f| f.either?('.', '..')} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end @@ -161,7 +162,7 @@ module ActiveSupport # Delete empty directories in the cache. def delete_empty_directories(dir) return if dir == cache_path - if Dir.entries(dir).reject{|f| ['.', '..'].include?(f)}.empty? + if Dir.entries(dir).reject{|f| f.either?('.', '..')}.empty? File.delete(dir) rescue nil delete_empty_directories(File.dirname(dir)) end -- cgit v1.2.3