Sha256: f109f79428f1d84d5c7dd1a87ee9d20fd83c2dd5f12c92cdab8553d828e40db2

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

module Georgia
  class MediaPolicy < ApplicationPolicy

    def index?
      media_user_permissions(:show_media_assets).include?(true)
    end

    def search?
      index?
    end

    def show?
      edit?
    end

    def new?
      create?
    end

    def create?
      media_user_permissions(:upload_media_assets).include?(true)
    end

    def edit?
      update?
    end

    def update?
      media_user_permissions(:update_media_assets).include?(true)
    end

    def destroy?
      media_user_permissions(:delete_media_assets).include?(true)
    end

    def download?
      media_user_permissions(:download_media_assets).include?(true)
    end

    # API calls

    def pictures?
      index?
    end

    private

    def media_permissions
      Georgia.permissions[:media_library]
    end

    def media_user_permissions action
      user_permissions(media_permissions, action)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
georgia-0.8.0 app/policies/georgia/media_policy.rb