diff options
-rw-r--r-- | actionpack/CHANGELOG.md | 2 | ||||
-rw-r--r-- | activemodel/CHANGELOG.md | 21 | ||||
-rw-r--r-- | activemodel/README.rdoc | 14 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 18 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_handling.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/core.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/log_subscriber.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/runtime_registry.rb | 25 | ||||
-rw-r--r-- | activesupport/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/per_thread_registry.rb | 45 | ||||
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 3 | ||||
-rw-r--r-- | railties/CHANGELOG.md | 2 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 17 |
13 files changed, 86 insertions, 77 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 913edbd8df..88cdd53336 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -64,7 +64,7 @@ *Brad Dunbar* * Include I18n locale fallbacks in view lookup. - Fixes GH#3512. + Fixes #3512. *Juan Barreneche* diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 9aee47bd52..a1f3d081db 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -3,6 +3,8 @@ * Add `ActiveModel::Errors#full_messages_for`, to return all the error messages for a given attribute. + Example: + class Person include ActiveModel::Validations @@ -19,26 +21,27 @@ * Added a method so that validations can be easily cleared on a model. For example: - class Person - include ActiveModel::Validations + class Person + include ActiveModel::Validations - validates_uniqueness_of :first_name - validate :cannot_be_robot + validates_uniqueness_of :first_name + validate :cannot_be_robot - def cannot_be_robot - errors.add(:base, 'A person cannot be a robot') if person_is_robot + def cannot_be_robot + errors.add(:base, 'A person cannot be a robot') if person_is_robot + end end - end Now, if someone runs `Person.clear_validators!`, then the following occurs: - Person.validators # => [] - Person._validate_callbacks.empty? # => true + Person.validators # => [] + Person._validate_callbacks.empty? # => true *John Wang* * `has_secure_password` does not fail the confirmation validation when assigning empty String to `password` and `password_confirmation`. + Fixes #9535. Example: diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index a66225319d..a399fe9051 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -24,8 +24,8 @@ to integrate with Action Pack out of the box: <tt>ActiveModel::Model</tt>. end person = Person.new(name: 'bob', age: '18') - person.name # => 'bob' - person.age # => '18' + person.name # => 'bob' + person.age # => '18' person.valid? # => true It includes model name introspections, conversions, translations and @@ -82,12 +82,12 @@ behavior out of the box: end person = Person.new - person.name # => nil - person.changed? # => false + person.name # => nil + person.changed? # => false person.name = 'bob' - person.changed? # => true - person.changed # => ['name'] - person.changes # => { 'name' => [nil, 'bob'] } + person.changed? # => true + person.changed # => ['name'] + person.changes # => { 'name' => [nil, 'bob'] } person.name = 'robert' person.save person.previous_changes # => {'name' => ['bob, 'robert']} diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index aa156f5d4f..062c548f20 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -6,11 +6,11 @@ Example: - cache = ActiveRecord::StatementCache.new do - Book.where(name: "my book").limit(100) - end + cache = ActiveRecord::StatementCache.new do + Book.where(name: "my book").limit(100) + end - books = cache.execute + books = cache.execute The solution attempts to get closer to the speed of `find_by_sql` but still maintaining the expressiveness of the Active Record queries. @@ -44,7 +44,6 @@ Ths solution is to build JoinAssociation when two relations with join information are being merged. And later while building the arel use the previously built `JoinAssociation` record in `JoinDependency#graft` to build the right from clause. - Fixes #3002. *Jared Armstrong and Neeraj Singh* @@ -76,7 +75,8 @@ *Michal Cichra* * `has_many` using `:through` now obeys the order clause mentioned in - through association. Fixes #10016. + through association. + Fixes #10016. *Neeraj Singh* @@ -141,7 +141,8 @@ *Ken Mazaika* * Add an `add_index` override in PostgreSQL adapter and MySQL adapter - to allow custom index type support. Fixes #6101. + to allow custom index type support. + Fixes #6101. add_index(:wikis, :body, :using => 'gin') @@ -165,7 +166,6 @@ in the association for a particular id. Then, it will go to the DB if it is not found. This is accomplished by calling `find_by_scan` in collection associations whenever `options[:inverse_of]` is not nil. - Fixes #9470. *John Wang* @@ -1275,7 +1275,7 @@ * Explain only normal CRUD sql (select / update / insert / delete). Fix problem that explains unexplainable sql. - Closes #7544 #6458. + Fixes #7544 #6458. *kennyj* diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 3f175988db..a1943dfcb0 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -54,11 +54,11 @@ module ActiveRecord end def connection_id - ActiveRecord::RuntimeRegistry.instance.connection_id + ActiveRecord::RuntimeRegistry.connection_id end def connection_id=(connection_id) - ActiveRecord::RuntimeRegistry.instance.connection_id = connection_id + ActiveRecord::RuntimeRegistry.connection_id = connection_id end # Returns the configuration of the associated connection as a hash: diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 7a8408155a..733d4e1c67 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -80,11 +80,11 @@ module ActiveRecord class_attribute :default_connection_handler, instance_writer: false def self.connection_handler - ActiveRecord::RuntimeRegistry.instance.connection_handler || self.default_connection_handler + ActiveRecord::RuntimeRegistry.connection_handler || default_connection_handler end def self.connection_handler=(handler) - ActiveRecord::RuntimeRegistry.instance.connection_handler = handler + ActiveRecord::RuntimeRegistry.connection_handler = handler end self.default_connection_handler = ConnectionAdapters::ConnectionHandler.new diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index 69371a1dab..61e5c120df 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -3,11 +3,11 @@ module ActiveRecord IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"] def self.runtime=(value) - ActiveRecord::RuntimeRegistry.instance.sql_runtime = value + ActiveRecord::RuntimeRegistry.sql_runtime = value end def self.runtime - ActiveRecord::RuntimeRegistry.instance.sql_runtime ||= 0 + ActiveRecord::RuntimeRegistry.sql_runtime ||= 0 end def self.reset_runtime diff --git a/activerecord/lib/active_record/runtime_registry.rb b/activerecord/lib/active_record/runtime_registry.rb index 3f0ac68143..17890dd29f 100644 --- a/activerecord/lib/active_record/runtime_registry.rb +++ b/activerecord/lib/active_record/runtime_registry.rb @@ -1,29 +1,14 @@ require 'active_support/per_thread_registry' module ActiveRecord - # This is a registry class for storing local variables in active record. The - # class allows you to access variables that are local to the current thread. - # These thread local variables are stored as attributes in the - # +RuntimeRegistry+ class. - # - # You can access the thread local variables by calling a variable's name on - # the +RuntimeRegistry+ class. For example, if you wanted to obtain the - # connection handler for the current thread, you would invoke: - # - # ActiveRecord::RuntimeRegistry.instance.connection_handler - # - # The +PerThreadRegistry+ module will make a new +RuntimeRegistry+ instance - # and store it in +Thread.current+. Whenever you make a call for an attribute - # on the +RuntimeRegistry+ class, the call will be sent to the instance that - # is stored in +Thread.current+. - # - # Note that you can also make the following call which would provide an - # equivalent result as the previous code: + # This is a thread locals registry for Active Record. For example # # ActiveRecord::RuntimeRegistry.connection_handler # - # However, this is less performant because it makes a call to +method_missing+ - # before it sends the method call to the +instance+. + # returns the connection handler local to the current thread. + # + # See the documentation of <tt>ActiveSupport::PerThreadRegistry</tt> + # for further details. class RuntimeRegistry extend ActiveSupport::PerThreadRegistry diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 821a4de0b3..545a9ec0af 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -8,8 +8,8 @@ * `fast_xs` support has been removed. Use `String#encode(xml: :attr)`. -* `ActiveSupport::Notifications::Instrumenter#instrument` should yield - its payload. +* `ActiveSupport::Notifications::Instrumenter#instrument` should + yield its payload. *stopdropandrew* diff --git a/activesupport/lib/active_support/per_thread_registry.rb b/activesupport/lib/active_support/per_thread_registry.rb index fb9a4c0e33..926df8b4cf 100644 --- a/activesupport/lib/active_support/per_thread_registry.rb +++ b/activesupport/lib/active_support/per_thread_registry.rb @@ -1,32 +1,35 @@ module ActiveSupport - # This module creates a local registry class inside each thread. It provides - # basic methods which will store thread locals in a single class. This - # prevents the proliferation of too many thread locals and allows you to - # explicitly keep track of each of the variables you're using as thread - # locals in a class which includes this module. + # This module is used to encapsulate access to thread local variables. # - # For example, instead of using a bunch of different thread locals to keep - # track of some variables like so: + # Given # - # Thread.current[:active_record_connection_handler] = connection_handler - # Thread.current[:active_record_sql_runtime] = sql_runtime + # module ActiveRecord + # class RuntimeRegistry + # extend ActiveSupport::PerThreadRegistry # - # You could use the following class which implements the +PerThreadRegistry+ - # module: + # attr_accessor :connection_handler + # end + # end # - # class NewRegistry - # extend ActiveSupport::PerThreadRegistry + # <tt>ActiveRecord::RuntimeRegistry</tt> gets an +instance+ class method + # that returns an instance of the class unique to the current thread. Thus, + # instead of polluting +Thread.current+ # - # attr_accessor :connection_handler, :sql_runtime - # end + # Thread.current[:connection_handler] + # + # you write + # + # ActiveRecord::RuntimeRegistry.instance.connection_handler + # + # A +method_missing+ handler that proxies to the thread local instance is + # installed in the extended class so the call above can be shortened to + # + # ActiveRecord::RuntimeRegistry.connection_handler # - # NewRegistry.instance.connection_handler = connection_handler - # NewRegistry.instance.sql_runtime = sql_runtime + # The instance is stored as a thread local keyed by the name of the class, + # that is the string "ActiveRecord::RuntimeRegistry" in the example above. # - # The new way of keeping track of the thread locals will create a new local - # inside of +Thread.current+ with a key which is the name of the extended - # class. Now you can easily access per thread variables by just calling the - # variable name on the registry. + # If the class has an initializer, it must accept no arguments. module PerThreadRegistry def instance Thread.current[self.name] ||= new diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 21a0620c22..3cf82a24b9 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -5,7 +5,7 @@ module ActiveSupport # The TimeZone class serves as a wrapper around TZInfo::Timezone instances. # It allows us to do the following: # - # * Limit the set of zones provided by TZInfo to a meaningful subset of 142 + # * Limit the set of zones provided by TZInfo to a meaningful subset of 146 # zones. # * Retrieve and display zones with a friendlier name # (e.g., "Eastern Time (US & Canada)" instead of "America/New_York"). @@ -177,6 +177,7 @@ module ActiveSupport "Wellington" => "Pacific/Auckland", "Nuku'alofa" => "Pacific/Tongatapu", "Tokelau Is." => "Pacific/Fakaofo", + "Chatham Is." => "Pacific/Chatham", "Samoa" => "Pacific/Apia" } diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index e4a08f68c1..f67177a047 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -58,7 +58,7 @@ * Improve service pages with new layout (404, etc). - *Stanislav Sobolev* + *Stanislav Sobolev* ## Rails 4.0.0.beta1 (February 25, 2013) ## diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index eb590da678..fa3ab969ae 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -79,6 +79,23 @@ module ApplicationTests assert_match "Hello world", output end + def test_should_not_eager_load_model_path_for_rake + add_to_config <<-RUBY + config.eager_load = true + + rake_tasks do + task do_nothing: :environment do + end + end + RUBY + + app_file "app/models/hello.rb", <<-RUBY + raise 'should not be pre-required for rake even `eager_load=true`' + RUBY + + Dir.chdir(app_path){ `rake do_nothing` } + end + def test_code_statistics_sanity assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0", Dir.chdir(app_path){ `rake stats` } |