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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Will merge once tests are green.

@eileencodes
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@eileencodes eileencodes merged commit beb63b2 into rails:master Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants