Class: Storytime::PostPolicy::Scope

Inherits:
Struct
  • Object
show all
Defined in:
app/policies/storytime/post_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



5
6
7
# File 'app/policies/storytime/post_policy.rb', line 5

def scope
  @scope
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



5
6
7
# File 'app/policies/storytime/post_policy.rb', line 5

def user
  @user
end

Instance Method Details

#resolveObject



6
7
8
9
10
11
12
13
# File 'app/policies/storytime/post_policy.rb', line 6

def resolve
  action = Storytime::Action.find_by(guid: "d8a1b1")
  if user.storytime_role_in_site(Storytime::Site.current).allowed_actions.include?(action)
    scope.all
  else
    scope.where(user_id: user.id)
  end
end