Class: Pageflow::EntryPolicy::Scope

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

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

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

#scopeObject (readonly)

Returns the value of attribute scope.



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

def scope
  @scope
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

Instance Method Details

#editor_or_aboveObject



20
21
22
# File 'app/policies/pageflow/entry_policy.rb', line 20

def editor_or_above
  query.with_role_at_least(:editor)
end

#manager_or_aboveObject



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

def manager_or_above
  query.with_role_at_least(:manager)
end

#member_addableObject



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

def member_addable
  publisher_or_above
end

#publisher_or_aboveObject



24
25
26
# File 'app/policies/pageflow/entry_policy.rb', line 24

def publisher_or_above
  query.with_role_at_least(:publisher)
end

#resolveObject



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

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