Class: Pageflow::AccountPolicy::Scope Private

Inherits:
Scope
  • Object
show all
Defined in:
app/policies/pageflow/account_policy.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Scope.



8
9
10
11
12
# File 'app/policies/pageflow/account_policy.rb', line 8

def initialize(user, scope)
  @user = user
  @scope = scope
  @query = AccountRoleQuery::Scope.new(user, scope)
end

Instance Attribute Details

#queryObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'app/policies/pageflow/account_policy.rb', line 6

def query
  @query
end

#scopeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'app/policies/pageflow/account_policy.rb', line 6

def scope
  @scope
end

#userObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'app/policies/pageflow/account_policy.rb', line 6

def user
  @user
end

Instance Method Details

#entry_creatableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
27
28
# File 'app/policies/pageflow/account_policy.rb', line 22

def entry_creatable
  if user.admin?
    scope.all
  else
    query.with_role_at_least(:publisher)
  end
end

#entry_movableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'app/policies/pageflow/account_policy.rb', line 30

def entry_movable
  entry_creatable
end

#folder_addableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'app/policies/pageflow/account_policy.rb', line 38

def folder_addable
  entry_creatable
end

#member_addableObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'app/policies/pageflow/account_policy.rb', line 42

def member_addable
  if user.admin?
    scope.all
  else
    query.with_role_at_least(:manager)
  end
end

#resolveObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



14
15
16
17
18
19
20
# File 'app/policies/pageflow/account_policy.rb', line 14

def resolve
  if user.admin?
    scope.all
  else
    query.with_role_at_least(:member)
  end
end

#sites_accessibleObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'app/policies/pageflow/account_policy.rb', line 34

def sites_accessible
  entry_creatable
end