Class: Pageflow::AccountRoleQuery::Scope

Inherits:
Scope
  • Object
show all
Defined in:
app/models/pageflow/account_role_query.rb

Overview

Query for accounts where a user has a given role.

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Create query scope.

Parameters:

  • user (User)

    User to query roles for.

  • scope (ActiveRecord::Relation)

    Scope of all accounts to filter from.



12
13
14
15
# File 'app/models/pageflow/account_role_query.rb', line 12

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

Instance Method Details

#with_role_at_least(role) ⇒ ActiveRecord::Relation

Find all accounts where user has at least given role.

Parameters:

  • role (String)

    Name of role.

Returns:

  • (ActiveRecord::Relation)


22
23
24
# File 'app/models/pageflow/account_role_query.rb', line 22

def with_role_at_least(role)
  scope.joins((role))
end