Class: Pageflow::SitePolicy

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/pageflow/site_policy.rb

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, site) ⇒ SitePolicy

Returns a new instance of SitePolicy.



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

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

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



38
39
40
# File 'app/policies/pageflow/site_policy.rb', line 38

def user
  @user
end

Instance Method Details

#read?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
# File 'app/policies/pageflow/site_policy.rb', line 45

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

#update?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/policies/pageflow/site_policy.rb', line 51

def update?
  read?
end