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

Improve Visibility profile contexts #5235

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

rmosolgo
Copy link
Owner

As discussed in #5231:

  • Always use context[:visibility_profile], route the query argument to that context key
  • When that key is present, used the configured context for .visible? calls (not the query context). The full query context is still used for dynamic queries (without context[:visibility_profile])
  • For good measure, freeze passed-in profile hashes.

@rmosolgo rmosolgo added this to the 2.4.10 milestone Feb 13, 2025
@rmosolgo rmosolgo merged commit 61816b0 into master Feb 13, 2025
15 checks passed
@rmosolgo rmosolgo deleted the better-profile-contexts branch February 13, 2025 13:50
@@ -13,6 +13,10 @@ class Visibility
# @param preload [Boolean] if `true`, load the default schema profile and all named profiles immediately (defaults to `true` for `Rails.env.production?`)
# @param migration_errors [Boolean] if `true`, raise an error when `Visibility` and `Warden` return different results
def self.use(schema, dynamic: false, profiles: EmptyObjects::EMPTY_HASH, preload: (defined?(Rails) ? Rails.env.production? : nil), migration_errors: false)
profiles&.each { |name, ctx|
ctx[:visibility_profile] = name
ctx.freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

Good call on freezing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants