Sha256: 4a751dadd358975bbd4eecd5c9ec35ace09bf12b728e9b0b8453e9b8e7d252bd

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require 'ditty/controllers/component'
require 'proxes/models/permission'
require 'ditty/policies/user_policy'
require 'ditty/policies/role_policy'
require 'proxes/policies/permission_policy'

module ProxES
  class Permissions < Ditty::Component
    set model_class: Permission

    FILTERS = [
      { name: :user, field: 'user.email' },
      { name: :role, field: 'role.name' },
      { name: :verb }
    ].freeze

    SEARCHABLE = %i[pattern].freeze

    helpers do
      def user_options
        policy_scope(::Ditty::User).as_hash(:email, :email)
      end

      def role_options
        policy_scope(::Ditty::Role).as_hash(:name, :name)
      end

      def verb_options
        ProxES::Permission.verbs
      end
    end

    def find_template(views, name, engine, &block)
      super(views, name, engine, &block) # Root
      super(::Ditty::ProxES.view_folder, name, engine, &block) # This Component
      super(::Ditty::App.view_folder, name, engine, &block) # Ditty
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
proxes-0.9.13 lib/proxes/controllers/permissions.rb
proxes-0.9.12 lib/proxes/controllers/permissions.rb
proxes-0.9.9 lib/proxes/controllers/permissions.rb
proxes-0.9.7 lib/proxes/controllers/permissions.rb
proxes-0.9.4 lib/proxes/controllers/permissions.rb