Class: Pageflow::AccountPolicy::Scope

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, scope) ⇒ Scope

Returns a new instance of Scope.



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

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

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



4
5
6
# File 'app/policies/pageflow/account_policy.rb', line 4

def query
  @query
end

#scopeObject (readonly)

Returns the value of attribute scope.



4
5
6
# File 'app/policies/pageflow/account_policy.rb', line 4

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'app/policies/pageflow/account_policy.rb', line 4

def user
  @user
end

Instance Method Details

#entry_creatableObject



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

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

#entry_movableObject



28
29
30
# File 'app/policies/pageflow/account_policy.rb', line 28

def entry_movable
  entry_creatable
end

#folder_addableObject



36
37
38
# File 'app/policies/pageflow/account_policy.rb', line 36

def folder_addable
  entry_creatable
end

#member_addableObject



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

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

#resolveObject



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

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

#themings_accessibleObject



32
33
34
# File 'app/policies/pageflow/account_policy.rb', line 32

def themings_accessible
  entry_creatable
end