Object
Most objects are cloneable, but not all. For example you can’t dup nil:
nil.dup # => TypeError: can't dup NilClass
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.
Included modules
- Benchmark
- FileUtils
- Java
- Rails::BacktraceFilterForTestUnit
- RequireProfiler
- W3CValidators
Constants
ALL = Mime::Type.new("*/*", :all, [])
AbstractRequest = ActionController::Request = ActionDispatch::Request
AbstractResponse = ActionController::Response = ActionDispatch::Response
FRAMEWORKS = %w( activesupport activemodel activerecord activeresource actionpack actionmailer railties )
HashWithIndifferentAccess = ActiveSupport::HashWithIndifferentAccess
Integration = ActionDispatch::Integration
IntegrationTest = ActionDispatch::IntegrationTest
MissingSourceFile = LoadError
N = Integer(ARGV.first)
PerformanceTest = ActionDispatch::PerformanceTest
Routing = ActionDispatch::Routing
TIMES = (ENV['N'] || 10000).to_i
Files
- actionpack/lib/action_controller/deprecated.rb
- actionpack/lib/action_controller/deprecated/integration_test.rb
- actionpack/lib/action_controller/deprecated/performance_test.rb
- actionpack/lib/action_dispatch/http/mime_types.rb
- activerecord/examples/performance.rb
- activesupport/lib/active_support/core_ext/kernel/agnostics.rb
- activesupport/lib/active_support/core_ext/load_error.rb
- activesupport/lib/active_support/core_ext/object/acts_like.rb
- activesupport/lib/active_support/core_ext/object/blank.rb
- activesupport/lib/active_support/core_ext/object/duplicable.rb
- activesupport/lib/active_support/core_ext/object/instance_variables.rb
- activesupport/lib/active_support/core_ext/object/returning.rb
- activesupport/lib/active_support/core_ext/object/to_param.rb
- activesupport/lib/active_support/core_ext/object/to_query.rb
- activesupport/lib/active_support/core_ext/object/try.rb
- activesupport/lib/active_support/core_ext/object/with_options.rb
- activesupport/lib/active_support/core_ext/string/output_safety.rb
- activesupport/lib/active_support/core_ext/uri.rb
- activesupport/lib/active_support/hash_with_indifferent_access.rb
- activesupport/lib/active_support/json/encoding.rb
- activesupport/lib/active_support/xml_mini/jdom.rb
- ci/ci_build.rb
- railties/guides/rails_guides.rb
- railties/guides/w3c_validator.rb
- railties/lib/rails/commands/benchmarker.rb
- railties/lib/rails/commands/plugin.rb
- railties/lib/rails/console/app.rb
- railties/lib/rails/console/helpers.rb
- railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
- railties/lib/rails/test_help.rb
- tasks/release.rb
- tools/profile