Sha256: 86408fb1e4f8505935b97f822792d6b3ac937e9114de81d864467125fd363ed5

Contents?: true

Size: 408 Bytes

Versions: 8

Compression:

Stored size: 408 Bytes

Contents

module Pageflow
  class EntryTemplatePolicy < ApplicationPolicy
    def initialize(user, entry_template)
      @user = user
      @entry_template = entry_template
    end

    def create?
      update?
    end

    def update?
      allows?(%w(publisher manager))
    end

    private

    def allows?(roles)
      @user.memberships.where(role: roles, entity: @entry_template.account).any?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-15.8.0 app/policies/pageflow/entry_template_policy.rb
pageflow-15.7.1 app/policies/pageflow/entry_template_policy.rb
pageflow-15.7.0 app/policies/pageflow/entry_template_policy.rb
pageflow-15.6.1 app/policies/pageflow/entry_template_policy.rb
pageflow-15.6.0 app/policies/pageflow/entry_template_policy.rb
pageflow-15.5.0 app/policies/pageflow/entry_template_policy.rb
pageflow-15.4.0 app/policies/pageflow/entry_template_policy.rb
pageflow-15.3.0 app/policies/pageflow/entry_template_policy.rb