From 733bfa63f5d8d3b963202b6d3e9f00b4db070b91 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Wed, 13 Apr 2011 00:04:40 +0800 Subject: [PATCH] Remove `#among?` from Active Support After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now. It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`. --- actionpack/lib/action_dispatch/routing/mapper.rb | 4 ++-- .../lib/action_dispatch/testing/assertions/response.rb | 2 +- actionpack/lib/action_dispatch/testing/integration.rb | 2 +- actionpack/test/controller/mime_responds_test.rb | 2 +- actionpack/test/dispatch/routing_test.rb | 2 +- actionpack/test/template/form_helper_test.rb | 2 +- actionpack/test/template/form_options_helper_test.rb | 2 +- actionpack/test/template/form_tag_helper_test.rb | 2 +- activemodel/lib/active_model/validator.rb | 2 +- .../lib/active_record/associations/association.rb | 2 +- .../lib/active_record/associations/builder/belongs_to.rb | 2 +- .../lib/active_record/associations/builder/has_many.rb | 2 +- .../lib/active_record/associations/builder/has_one.rb | 2 +- .../active_record/associations/has_one_association.rb | 2 +- .../attribute_methods/time_zone_conversion.rb | 2 +- activerecord/lib/active_record/railties/databases.rake | 2 +- activerecord/lib/active_record/reflection.rb | 2 +- .../session_migration/session_migration_generator.rb | 2 +- activerecord/test/cases/attribute_methods_test.rb | 2 +- activerecord/test/cases/defaults_test.rb | 2 +- activeresource/lib/active_resource/connection.rb | 2 +- activeresource/test/cases/http_mock_test.rb | 2 +- activesupport/CHANGELOG | 2 +- activesupport/lib/active_support/cache/file_store.rb | 4 ++-- activesupport/lib/active_support/callbacks.rb | 2 +- .../lib/active_support/core_ext/object/inclusion.rb | 9 --------- activesupport/lib/active_support/time_with_zone.rb | 2 +- activesupport/test/core_ext/object/inclusion_test.rb | 6 ------ activesupport/test/transliterate_test.rb | 2 +- railties/guides/rails_guides/textile_extensions.rb | 4 ++-- railties/lib/rails/commands.rb | 2 +- railties/lib/rails/commands/benchmarker.rb | 2 +- railties/lib/rails/commands/destroy.rb | 2 +- railties/lib/rails/commands/generate.rb | 2 +- railties/lib/rails/commands/profiler.rb | 2 +- railties/lib/rails/generators/base.rb | 2 +- railties/lib/rails/generators/generated_attribute.rb | 2 +- 37 files changed, 38 insertions(+), 53 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 13aef18ee1..a65f6e1fce 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1346,11 +1346,11 @@ module ActionDispatch end def resource_scope? #:nodoc: - @scope[:scope_level].among?(:resource, :resources) + @scope[:scope_level].in?([:resource, :resources]) end def resource_method_scope? #:nodoc: - @scope[:scope_level].among?(:collection, :member, :new) + @scope[:scope_level].in?([:collection, :member, :new]) end def with_exclusive_scope diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 16a6b93ce8..8a04cfa886 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -35,7 +35,7 @@ module ActionDispatch def assert_response(type, message = nil) validate_request! - if type.among?(:success, :missing, :redirect, :error) && @response.send("#{type}?") + if type.in?([:success, :missing, :redirect, :error]) && @response.send("#{type}?") assert_block("") { true } # to count the assertion elsif type.is_a?(Fixnum) && @response.response_code == type assert_block("") { true } # to count the assertion diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 174babb9aa..7d707d03a9 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -321,7 +321,7 @@ module ActionDispatch define_method(method) do |*args| reset! unless integration_session # reset the html_document variable, but only for new get/post calls - @html_document = nil unless method.among?("cookies", "assigns") + @html_document = nil unless method.in?(["cookies", "assigns"]) integration_session.__send__(method, *args).tap do copy_session_variables! end diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 9e09fc39ed..4a5e597500 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -157,7 +157,7 @@ class RespondToController < ActionController::Base protected def set_layout - if action_name.among?("all_types_with_layout", "iphone_with_html_response_type") + if action_name.in?(["all_types_with_layout", "iphone_with_html_response_type"]) "respond_to/layouts/standard" elsif action_name == "iphone_with_html_response_type_without_layout" "respond_to/layouts/missing" diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index cf7a5aaa3b..ba7506721f 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -496,7 +496,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resources :todos, :id => /\d+/ end - scope '/countries/:country', :constraints => lambda { |params, req| params[:country].among?("all", "France") } do + scope '/countries/:country', :constraints => lambda { |params, req| params[:country].in?(["all", "France"]) } do match '/', :to => 'countries#index' match '/cities', :to => 'countries#cities' end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index 435ce81238..7afab3179c 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -1744,7 +1744,7 @@ class FormHelperTest < ActionView::TestCase def snowman(method = nil) txt = %{
} txt << %{} - if method && !method.to_s.among?('get', 'post') + if method && !method.to_s.in?(['get', 'post']) txt << %{} end txt << %{
} diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb index 76236aee41..b92e1d9890 100644 --- a/actionpack/test/template/form_options_helper_test.rb +++ b/actionpack/test/template/form_options_helper_test.rb @@ -83,7 +83,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_collection_options_with_proc_for_disabled assert_dom_equal( "\n\n", - options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => lambda{|p| p.author_name.among?("Babe", "Cabe") }) + options_from_collection_for_select(dummy_posts, "author_name", "title", :disabled => lambda{|p| p.author_name.in?(["Babe", "Cabe"]) }) ) end diff --git a/actionpack/test/template/form_tag_helper_test.rb b/actionpack/test/template/form_tag_helper_test.rb index aa2114ff79..656fa0356b 100644 --- a/actionpack/test/template/form_tag_helper_test.rb +++ b/actionpack/test/template/form_tag_helper_test.rb @@ -14,7 +14,7 @@ class FormTagHelperTest < ActionView::TestCase txt = %{
} txt << %{} - if method && !method.to_s.among?('get','post') + if method && !method.to_s.in?(['get','post']) txt << %{} end txt << %{
} diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 5f7f7a6ad6..5304743389 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -68,7 +68,7 @@ module ActiveModel #:nodoc: # # class TitleValidator < ActiveModel::EachValidator # def validate_each(record, attribute, value) - # record.errors[attribute] << 'must be Mr. Mrs. or Dr.' unless value.among?('Mr.', 'Mrs.', 'Dr.') + # record.errors[attribute] << 'must be Mr. Mrs. or Dr.' unless value.in?(['Mr.', 'Mrs.', 'Dr.']) # end # end # diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 66f6477ec5..687b668634 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -164,7 +164,7 @@ module ActiveRecord def creation_attributes attributes = {} - if reflection.macro.among?(:has_one, :has_many) && !options[:through] + if reflection.macro.in?([:has_one, :has_many]) && !options[:through] attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key] if reflection.options[:as] diff --git a/activerecord/lib/active_record/associations/builder/belongs_to.rb b/activerecord/lib/active_record/associations/builder/belongs_to.rb index 763b12f708..f6d26840c2 100644 --- a/activerecord/lib/active_record/associations/builder/belongs_to.rb +++ b/activerecord/lib/active_record/associations/builder/belongs_to.rb @@ -67,7 +67,7 @@ module ActiveRecord::Associations::Builder def configure_dependency if options[:dependent] - unless options[:dependent].among?(:destroy, :delete) + unless options[:dependent].in?([:destroy, :delete]) raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{options[:dependent].inspect})" end diff --git a/activerecord/lib/active_record/associations/builder/has_many.rb b/activerecord/lib/active_record/associations/builder/has_many.rb index 67ce339380..ecbc70888f 100644 --- a/activerecord/lib/active_record/associations/builder/has_many.rb +++ b/activerecord/lib/active_record/associations/builder/has_many.rb @@ -16,7 +16,7 @@ module ActiveRecord::Associations::Builder def configure_dependency if options[:dependent] - unless options[:dependent].among?(:destroy, :delete_all, :nullify, :restrict) + unless options[:dependent].in?([:destroy, :delete_all, :nullify, :restrict]) raise ArgumentError, "The :dependent option expects either :destroy, :delete_all, " \ ":nullify or :restrict (#{options[:dependent].inspect})" end diff --git a/activerecord/lib/active_record/associations/builder/has_one.rb b/activerecord/lib/active_record/associations/builder/has_one.rb index 18d7117bb7..88c0d3e90f 100644 --- a/activerecord/lib/active_record/associations/builder/has_one.rb +++ b/activerecord/lib/active_record/associations/builder/has_one.rb @@ -29,7 +29,7 @@ module ActiveRecord::Associations::Builder def configure_dependency if options[:dependent] - unless options[:dependent].among?(:destroy, :delete, :nullify, :restrict) + unless options[:dependent].in?([:destroy, :delete, :nullify, :restrict]) raise ArgumentError, "The :dependent option expects either :destroy, :delete, " \ ":nullify or :restrict (#{options[:dependent].inspect})" end diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index aaa8b97389..7134dc85c8 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -52,7 +52,7 @@ module ActiveRecord end def remove_target!(method) - if method.among?(:delete, :destroy) + if method.in?([:delete, :destroy]) target.send(method) else nullify_owner_attributes(target) diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb index 67b0e77a25..62a3cfa9a5 100644 --- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb +++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb @@ -59,7 +59,7 @@ module ActiveRecord private def create_time_zone_conversion_attribute?(name, column) - time_zone_aware_attributes && !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) && column.type.among?(:datetime, :timestamp) + time_zone_aware_attributes && !self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) && column.type.in?([:datetime, :timestamp]) end end end diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 944a29a3e6..6b3c38cb58 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -137,7 +137,7 @@ db_namespace = namespace :db do end def local_database?(config, &block) - if config['host'].among?("127.0.0.1", "localhost") || config['host'].blank? + if config['host'].in?(["127.0.0.1", "localhost"]) || config['host'].blank? yield else $stderr.puts "This task only modifies local databases. #{config['database']} is on a remote host." diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index eac6a5dcad..bcba85d7a4 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -164,7 +164,7 @@ module ActiveRecord def initialize(macro, name, options, active_record) super - @collection = macro.among?(:has_many, :has_and_belongs_to_many) + @collection = macro.in?([:has_many, :has_and_belongs_to_many]) end # Returns a new, unsaved instance of the associated class. +options+ will diff --git a/activerecord/lib/rails/generators/active_record/session_migration/session_migration_generator.rb b/activerecord/lib/rails/generators/active_record/session_migration/session_migration_generator.rb index d80c8ba996..90923f6e74 100644 --- a/activerecord/lib/rails/generators/active_record/session_migration/session_migration_generator.rb +++ b/activerecord/lib/rails/generators/active_record/session_migration/session_migration_generator.rb @@ -14,7 +14,7 @@ module ActiveRecord def session_table_name current_table_name = ActiveRecord::SessionStore::Session.table_name - if current_table_name.among?("sessions", "session") + if current_table_name.in?(["sessions", "session"]) current_table_name = (ActiveRecord::Base.pluralize_table_names ? 'session'.pluralize : 'session') end current_table_name diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index a3c5c14758..b898c003bd 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -639,7 +639,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase end def time_related_columns_on_topic - Topic.columns.select { |c| c.type.among?(:time, :date, :datetime, :timestamp) } + Topic.columns.select { |c| c.type.in?([:time, :date, :datetime, :timestamp]) } end def serialized_columns_on_topic diff --git a/activerecord/test/cases/defaults_test.rb b/activerecord/test/cases/defaults_test.rb index 42b14bd25c..b3a281d960 100644 --- a/activerecord/test/cases/defaults_test.rb +++ b/activerecord/test/cases/defaults_test.rb @@ -95,7 +95,7 @@ if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter) assert_equal 0, klass.columns_hash['zero'].default assert !klass.columns_hash['zero'].null # 0 in MySQL 4, nil in 5. - assert klass.columns_hash['omit'].default.among?(0, nil) + assert klass.columns_hash['omit'].default.in?([0, nil]) assert !klass.columns_hash['omit'].null assert_raise(ActiveRecord::StatementInvalid) { klass.create! } diff --git a/activeresource/lib/active_resource/connection.rb b/activeresource/lib/active_resource/connection.rb index e286362f87..765575d866 100644 --- a/activeresource/lib/active_resource/connection.rb +++ b/activeresource/lib/active_resource/connection.rb @@ -278,7 +278,7 @@ module ActiveResource def legitimize_auth_type(auth_type) return :basic if auth_type.nil? auth_type = auth_type.to_sym - auth_type.among?(:basic, :digest) ? auth_type : :basic + auth_type.in?([:basic, :digest]) ? auth_type : :basic end end end diff --git a/activeresource/test/cases/http_mock_test.rb b/activeresource/test/cases/http_mock_test.rb index dfb097315e..cd5155924a 100644 --- a/activeresource/test/cases/http_mock_test.rb +++ b/activeresource/test/cases/http_mock_test.rb @@ -193,7 +193,7 @@ class HttpMockTest < ActiveSupport::TestCase end def request(method, path, headers = {}, body = nil) - if method.among?(:put, :post) + if method.in?([:put, :post]) @http.send(method, path, body, headers) else @http.send(method, path, headers) diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index eb027795a8..163f1c932c 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,6 +1,6 @@ *Rails 3.1.0 (unreleased)* -* Add Object#in? to test if an object is included in another object, and Object#among? to test if an object is included in a list of objects which will be passed as arguments. [Prem Sichanugrist, Brian Morearty, John Reitano] +* Add Object#in? to test if an object is included in another object [Prem Sichanugrist, Brian Morearty, John Reitano] * LocalCache strategy is now a real middleware class, not an anonymous class posing for pictures. diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index bdef47a237..9936b33e22 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -21,7 +21,7 @@ module ActiveSupport end def clear(options = nil) - root_dirs = Dir.entries(cache_path).reject{|f| f.among?('.', '..')} + root_dirs = Dir.entries(cache_path).reject{|f| f.in?(['.', '..'])} FileUtils.rm_r(root_dirs.collect{|f| File.join(cache_path, f)}) end @@ -162,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| f.among?('.', '..')}.empty? + if Dir.entries(dir).reject{|f| f.in?(['.', '..'])}.empty? File.delete(dir) rescue nil delete_empty_directories(File.dirname(dir)) end diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 6a0bffb6d7..656cba625c 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -413,7 +413,7 @@ module ActiveSupport # CallbackChain. # def __update_callbacks(name, filters = [], block = nil) #:nodoc: - type = filters.first.among?(:before, :after, :around) ? filters.shift : :before + type = filters.first.in?([:before, :after, :around]) ? filters.shift : :before options = filters.last.is_a?(Hash) ? filters.pop : {} filters.unshift(block) if block diff --git a/activesupport/lib/active_support/core_ext/object/inclusion.rb b/activesupport/lib/active_support/core_ext/object/inclusion.rb index cf89288aed..cc7edc0f17 100644 --- a/activesupport/lib/active_support/core_ext/object/inclusion.rb +++ b/activesupport/lib/active_support/core_ext/object/inclusion.rb @@ -8,13 +8,4 @@ class Object def in?(another_object) another_object.include?(self) end - - # Returns true if this object is included in the argument list. Usage: - # - # username = "sikachu" - # username.among?("josevalim", "dhh", "wycats") # => false - # - def among?(*objects) - objects.include?(self) - end end diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 6b9120e51f..3d092529d6 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -345,7 +345,7 @@ module ActiveSupport end def duration_of_variable_length?(obj) - ActiveSupport::Duration === obj && obj.parts.any? {|p| p[0].among?(:years, :months, :days) } + ActiveSupport::Duration === obj && obj.parts.any? {|p| p[0].in?([:years, :months, :days]) } end end end diff --git a/activesupport/test/core_ext/object/inclusion_test.rb b/activesupport/test/core_ext/object/inclusion_test.rb index 9f2ace0ef7..382271d42d 100644 --- a/activesupport/test/core_ext/object/inclusion_test.rb +++ b/activesupport/test/core_ext/object/inclusion_test.rb @@ -30,12 +30,6 @@ class InTest < Test::Unit::TestCase assert !3.in?(s) end - def test_among - assert 1.among?(1,2,3) - assert !5.among?(1,2,3) - assert [1,2,3].among?([1,2,3], 2, [3,4,5]) - end - module A end class B diff --git a/activesupport/test/transliterate_test.rb b/activesupport/test/transliterate_test.rb index 90b40b5478..08e11d4f38 100644 --- a/activesupport/test/transliterate_test.rb +++ b/activesupport/test/transliterate_test.rb @@ -16,7 +16,7 @@ class TransliterateTest < Test::Unit::TestCase # create string with range of Unicode"s western characters with # diacritics, excluding the division and multiplication signs which for # some reason or other are floating in the middle of all the letters. - string = (0xC0..0x17E).to_a.reject {|c| c.among?(0xD7, 0xF7)}.pack("U*") + string = (0xC0..0x17E).to_a.reject {|c| c.in?([0xD7, 0xF7])}.pack("U*") string.each_char do |char| assert_match %r{^[a-zA-Z']*$}, ActiveSupport::Inflector.transliterate(string) end diff --git a/railties/guides/rails_guides/textile_extensions.rb b/railties/guides/rails_guides/textile_extensions.rb index 9beeefb551..352c5e91dd 100644 --- a/railties/guides/rails_guides/textile_extensions.rb +++ b/railties/guides/rails_guides/textile_extensions.rb @@ -5,7 +5,7 @@ module RailsGuides def notestuff(body) body.gsub!(/^(IMPORTANT|CAUTION|WARNING|NOTE|INFO)[.:](.*)$/) do |m| css_class = $1.downcase - css_class = 'warning' if css_class.among?('caution', 'important') + css_class = 'warning' if css_class.in?(['caution', 'important']) result = "

" result << $2.strip @@ -35,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 = $1.among?('erb', 'shell') ? 'html' : $1 + css_class = $1.in?(['erb', 'shell']) ? 'html' : $1 %{

#{es}
} end end diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 7108d4157e..4182757346 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -71,7 +71,7 @@ when '--version', '-v' require 'rails/commands/application' else - puts "Error: Command not recognized" unless command.among?('-h', '--help') + puts "Error: Command not recognized" unless command.in?(['-h', '--help']) puts <<-EOT Usage: rails COMMAND [ARGS] diff --git a/railties/lib/rails/commands/benchmarker.rb b/railties/lib/rails/commands/benchmarker.rb index e10ec8fd38..f230f405c0 100644 --- a/railties/lib/rails/commands/benchmarker.rb +++ b/railties/lib/rails/commands/benchmarker.rb @@ -1,6 +1,6 @@ require 'active_support/core_ext/object/inclusion' -if ARGV.first.among?(nil, "-h", "--help") +if ARGV.first.in?([nil, "-h", "--help"]) puts "Usage: rails benchmarker [times] 'Person.expensive_way' 'Person.another_expensive_way' ..." exit 1 end diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index d082ba592c..2a84e2a6df 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/object/inclusion' Rails::Generators.configure! -if ARGV.first.among?(nil, "-h", "--help") +if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'destroy' exit end diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 789e5ebedb..28c1c56352 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -3,7 +3,7 @@ require 'active_support/core_ext/object/inclusion' Rails::Generators.configure! -if ARGV.first.among?(nil, "-h", "--help") +if ARGV.first.in?([nil, "-h", "--help"]) Rails::Generators.help 'generate' exit end diff --git a/railties/lib/rails/commands/profiler.rb b/railties/lib/rails/commands/profiler.rb index d3195a204e..7959d8a981 100644 --- a/railties/lib/rails/commands/profiler.rb +++ b/railties/lib/rails/commands/profiler.rb @@ -1,6 +1,6 @@ require 'active_support/core_ext/object/inclusion' -if ARGV.first.among?(nil, "-h", "--help") +if ARGV.first.in?([nil, "-h", "--help"]) $stderr.puts "Usage: rails profiler 'Person.expensive_method(10)' [times] [flat|graph|graph_html]" exit(1) end diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 2b0eaea3a4..8d03cb911b 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -165,7 +165,7 @@ module Rails names.each do |name| defaults = if options[:type] == :boolean { } - elsif default_value_for_option(name, options).among?(true, false) + elsif default_value_for_option(name, options).in?([true, false]) { :banner => "" } else { :desc => "#{name.to_s.humanize} to be invoked", :banner => "NAME" } diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index f85375b2a3..b26161f1d0 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -45,7 +45,7 @@ module Rails end def reference? - self.type.among?(:references, :belongs_to) + self.type.in?([:references, :belongs_to]) end end end