Sha256: 989128582d5df2779fff3833d62f800b134beb095a0ca665d841d07cb49c2b83

Contents?: true

Size: 1019 Bytes

Versions: 6

Compression:

Stored size: 1019 Bytes

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]

    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

6 entries across 6 versions & 1 rubygems

Version Path
proxes-0.9.2 lib/proxes/controllers/permissions.rb
proxes-0.9.1 lib/proxes/controllers/permissions.rb
proxes-0.9.0 lib/proxes/controllers/permissions.rb
proxes-0.8.6 lib/proxes/controllers/permissions.rb
proxes-0.8.5 lib/proxes/controllers/permissions.rb
proxes-0.8.4 lib/proxes/controllers/permissions.rb