Class: Pageflow::EntryPolicy::Scope Private

Inherits:
Scope
  • Object
show all
Defined in:
app/policies/pageflow/entry_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/entry_policy.rb', line 8

def initialize(user, scope)
  @user = user
  @scope = scope
  @query = EntryRoleQuery::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/entry_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/entry_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/entry_policy.rb', line 6

def user
  @user
end

Instance Method Details

#editor_or_aboveObject

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
# File 'app/policies/pageflow/entry_policy.rb', line 22

def editor_or_above
  query.with_role_at_least(:editor)
end

#manager_or_aboveObject

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/entry_policy.rb', line 34

def manager_or_above
  query.with_role_at_least(:manager)
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.



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

def member_addable
  publisher_or_above
end

#publisher_or_aboveObject

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.



26
27
28
# File 'app/policies/pageflow/entry_policy.rb', line 26

def publisher_or_above
  query.with_role_at_least(:publisher)
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/entry_policy.rb', line 14

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