Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ActiveRecord::Base.connected_to? #34680

Merged
merged 1 commit into from Dec 12, 2018

Conversation

@jhawthorn
Copy link
Member

@jhawthorn jhawthorn commented Dec 11, 2018

This can be used to check the currently connected role. It's meant to mirror ActiveRecord::Base.connected_to introduced in #34052

Usage:

ActiveRecord::Base.connected_to(role: :writing) do
  ActiveRecord::Base.connected_to?(role: :writing) #=> true
  ActiveRecord::Base.connected_to?(role: :reading) #=> false
end

cc @eileencodes

@eileencodes eileencodes self-assigned this Dec 11, 2018
Copy link
Member

@eileencodes eileencodes left a comment

Looks great! Will merge once tests are green.

@eileencodes
Copy link
Member

@eileencodes eileencodes commented Dec 11, 2018

Sign codeclimate. We use assert_not over refute, can you update? https://codeclimate.com/github/rails/rails/pull/34680

current_role == role.to_sym
end

def current_role

This comment has been minimized.

@rafaelfranca

rafaelfranca Dec 11, 2018
Member

Is this a public API method? If yes, it needs to be documented.

This can be used to check the currently connected role. It's meant to
mirror AR::Base.connected_to
@jhawthorn jhawthorn force-pushed the jhawthorn:connected_to_question branch from 23b70db to b67a3f5 Dec 11, 2018
@eileencodes eileencodes merged commit beb63b2 into rails:master Dec 12, 2018
2 checks passed
2 checks passed
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants