diff options
author | John Hawthorn <john@hawthorn.email> | 2019-02-07 11:59:45 -0800 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2019-02-07 14:32:54 -0800 |
commit | a68bcde50660ba3adf4a2659f46212ad319cfeea (patch) | |
tree | 1145ff3f0faea8ef0e44c06fd3970a14f6c170d1 /activerecord/lib/active_record/middleware/database_selector.rb | |
parent | ed1f392ea6f3919aceda2d45f08cfa34780750f1 (diff) | |
download | rails-a68bcde50660ba3adf4a2659f46212ad319cfeea.tar.gz rails-a68bcde50660ba3adf4a2659f46212ad319cfeea.tar.bz2 rails-a68bcde50660ba3adf4a2659f46212ad319cfeea.zip |
Rename database selector operations to context
Diffstat (limited to 'activerecord/lib/active_record/middleware/database_selector.rb')
-rw-r--r-- | activerecord/lib/active_record/middleware/database_selector.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/middleware/database_selector.rb b/activerecord/lib/active_record/middleware/database_selector.rb index b95d8d6cb6..aad263695b 100644 --- a/activerecord/lib/active_record/middleware/database_selector.rb +++ b/activerecord/lib/active_record/middleware/database_selector.rb @@ -12,8 +12,8 @@ module ActiveRecord # # The resolver class defines when the application should switch (i.e. read # from the primary if a write occurred less than 2 seconds ago) and an - # operations class that sets a value that helps the resolver class decide - # when to switch. + # resolver context class that sets a value that helps the resolver class + # decide when to switch. # # Rails default middleware uses the request's session to set a timestamp # that informs the application when to read from a primary or read from a @@ -24,7 +24,7 @@ module ActiveRecord # # config.active_record.database_selector = { delay: 2.seconds } # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver - # config.active_record.database_operations = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session # # New applications will include these lines commented out in the production.rb. # @@ -33,16 +33,16 @@ module ActiveRecord # # config.active_record.database_selector = { delay: 2.seconds } # config.active_record.database_resolver = MyResolver - # config.active_record.database_operations = MyResolver::MySession + # config.active_record.database_resolver_context = MyResolver::MySession class DatabaseSelector - def initialize(app, resolver_klass = Resolver, operations_klass = Resolver::Session, options = {}) + def initialize(app, resolver_klass = Resolver, context_klass = Resolver::Session, options = {}) @app = app @resolver_klass = resolver_klass - @operations_klass = operations_klass + @context_klass = context_klass @options = options end - attr_reader :resolver_klass, :operations_klass, :options + attr_reader :resolver_klass, :context_klass, :options # Middleware that determines which database connection to use in a multiple # database application. @@ -57,13 +57,13 @@ module ActiveRecord private def select_database(request, &blk) - operations = operations_klass.call(request) - database_resolver = resolver_klass.call(operations, options) + context = context_klass.call(request) + resolver = resolver_klass.call(context, options) if reading_request?(request) - database_resolver.read(&blk) + resolver.read(&blk) else - database_resolver.write(&blk) + resolver.write(&blk) end end |