Most objects are cloneable, but not all. For example you can’t dup
nil:
nil.dup
Classes may signal their instances are not duplicable removing
dup/clone or raising exceptions from them. So, to dup an arbitrary
object you normally use an optimistic approach and are ready to catch an
exception, say:
arbitrary_object.dup rescue object
Rails dups objects in a few critical spots where
they are not that arbitrary. That rescue is very expensive (like 40 times
slower than a predicate), and it is often triggered.
That’s why we hardcode the following cases and check duplicable? instead of using that
rescue idiom.
Constants
ALL = Mime::Type.new("*/*", :all, [])
AbstractRequest = ActionController::Request = ActionDispatch::Request
AbstractResponse = ActionController::Response = ActionDispatch::Response
Routing = ActionDispatch::Routing
Integration = ActionDispatch::Integration
IntegrationTest = ActionDispatch::IntegrationTest
PerformanceTest = ActionDispatch::PerformanceTest
N = Integer(ARGV.first)
HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess
MissingSourceFile = LoadError
FRAMEWORKS = %w( activesupport activemodel activerecord activeresource actionpack actionmailer railties )
TIMES = (ENV['N'] || 10000).to_i
Attributes
Show files where this class is defined (32 files)
actionpack/lib/action_dispatch/http/mime_types.rb
actionpack/lib/action_controller/deprecated.rb
actionpack/lib/action_controller/deprecated/integration_test.rb
actionpack/lib/action_controller/deprecated/performance_test.rb
railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
railties/lib/rails/console/helpers.rb
railties/lib/rails/console/app.rb
railties/lib/rails/commands/plugin.rb
railties/lib/rails/commands/benchmarker.rb
railties/lib/rails/test_help.rb
railties/guides/w3c_validator.rb
railties/guides/rails_guides.rb
ci/ci_build.rb
activesupport/lib/active_support/json/encoding.rb
activesupport/lib/active_support/hash_with_indifferent_access.rb
activesupport/lib/active_support/core_ext/load_error.rb
activesupport/lib/active_support/core_ext/string/output_safety.rb
activesupport/lib/active_support/core_ext/kernel/agnostics.rb
activesupport/lib/active_support/core_ext/uri.rb
activesupport/lib/active_support/core_ext/object/instance_variables.rb
activesupport/lib/active_support/core_ext/object/try.rb
activesupport/lib/active_support/core_ext/object/to_query.rb
activesupport/lib/active_support/core_ext/object/with_options.rb
activesupport/lib/active_support/core_ext/object/to_param.rb
activesupport/lib/active_support/core_ext/object/acts_like.rb
activesupport/lib/active_support/core_ext/object/duplicable.rb
activesupport/lib/active_support/core_ext/object/returning.rb
activesupport/lib/active_support/core_ext/object/blank.rb
activesupport/lib/active_support/xml_mini/jdom.rb
tools/profile
tasks/release.rb
activerecord/examples/performance.rb