Skip to content

Instantly share code, notes, and snippets.

@thiago-sydow
Last active December 26, 2017 15:53
Show Gist options
  • Save thiago-sydow/2fd3f111ee211b544bed0ef0ecdc6543 to your computer and use it in GitHub Desktop.
Save thiago-sydow/2fd3f111ee211b544bed0ef0ecdc6543 to your computer and use it in GitHub Desktop.
Files used in the Medium post about Field Instrumentation Raw
def authorization_proc(field)
permission = field.metadata[:scoped_collection]
original_resolve_proc = field.resolve_proc
->(obj, args, ctx) {
initial_scope = original_resolve_proc.call(obj, args, ctx)
scope = permission[:policy_class]::Scope.new(ctx[:current_user], initial_scope)
resolved = scope.resolve
resolved
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment