Class: Pageflow::SitePolicy Private

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/pageflow/site_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.

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, site) ⇒ SitePolicy

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 SitePolicy.



42
43
44
45
# File 'app/policies/pageflow/site_policy.rb', line 42

def initialize(user, site)
  @user = user
  @account_role_query = AccountRoleQuery.new(user, site.)
end

Instance Attribute Details

#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.



40
41
42
# File 'app/policies/pageflow/site_policy.rb', line 40

def user
  @user
end

Instance Method Details

#manage_root_entry?Boolean

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:

  • (Boolean)


57
58
59
60
# File 'app/policies/pageflow/site_policy.rb', line 57

def manage_root_entry?
  @user.admin? ||
    @account_role_query.has_at_least_role?(:manager)
end

#read?Boolean

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:

  • (Boolean)


47
48
49
50
51
# File 'app/policies/pageflow/site_policy.rb', line 47

def read?
  @user.admin? ||
    (@account_role_query.has_at_least_role?(:manager) &&
     Pageflow.config.allow_multiaccount_users)
end

#update?Boolean

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:

  • (Boolean)


53
54
55
# File 'app/policies/pageflow/site_policy.rb', line 53

def update?
  read?
end