Class: ApplicationPolicy::Scope

Inherits:
Object
  • Object
show all
Defined in:
app/policies/application_policy.rb

Overview

Restricts ActiveRecord queries using scopes based on the user's access permissions

Instance Method Summary collapse

Constructor Details

#initialize(organization_user, scope) ⇒ Scope

Returns a new instance of Scope

Parameters:

  • organization_user (Coyote::OrganizationUser)
  • scope (ActiveRecord::Associations::CollectionProxy)

    the scope upon which to base ActiveRecord queries, which this class may scope further



75
76
77
78
# File 'app/policies/application_policy.rb', line 75

def initialize(organization_user, scope)
  @organization_user = organization_user
  @scope = scope
end

Instance Method Details

#resolveActiveRecord::Associations::CollectionProxy

Returns the scope upon which to base ActiveRecord queries, restricted to records the organization user can access

Returns:

  • (ActiveRecord::Associations::CollectionProxy)

    the scope upon which to base ActiveRecord queries, restricted to records the organization user can access



81
82
83
# File 'app/policies/application_policy.rb', line 81

def resolve
  scope
end