Sha256: 281d3695dfd7aef0f53349627d17260fa807137d6a3c91e4f68daad4bff75605
Contents?: true
Size: 1.25 KB
Versions: 15
Compression:
Stored size: 1.25 KB
Contents
module Locomotive class ApplicationPolicy class Scope attr_reader :membership, :scope def initialize(membership, scope) @membership = membership @scope = scope end end delegate :site, :account, to: :membership attr_reader :membership, :resource # The resource is always scoped by the site defined by the membership. def initialize(membership, resource) @membership = membership @resource = resource raise Pundit::NotAuthorizedError, 'must be logged in' unless account raise Pundit::NotAuthorizedError, 'should have a resource' unless resource end def index? false end def show? index? end def edit? update? end def update? false end def new? create? end def create? false end def destroy? false end def destroy_all? false end def site_staff? membership.site.present? end def super_admin? account.super_admin? end def site_admin_or_designer? membership.admin? || membership.designer? end def site_admin? membership.admin? end def persisted? resource.try(:persisted?) end end end
Version data entries
15 entries across 15 versions & 1 rubygems