Sha256: e8087b7e85d661f35e3d7b4ec1cf3a909ef4d3392041cc3f2185b4a2f48d4a52
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require 'byebug' require_relative 'verify_instance' module PermissionSettings # Class that defines core functionality class Patcher attr_reader :klass def initialize(klass) @klass = klass end def self.call(klass) new(klass).call end def call setup_settings_interface setup_instance_verification end private def setup_settings_interface klass.class_eval do has_settings do |s| s.key PermissionSettings.configuration.scope_name(self), defaults: PermissionSettings.configuration.load_permissions_file(self) end end end def setup_instance_verification role_method = PermissionSettings.configuration.role_access_method klass.class_eval do define_method(:can?) do |*keys, resource: nil, &block| PermissionSettings::VerifyInstance.call(keys, role: send(role_method), resource: resource, &block) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
permission_settings-1.0.1 | lib/permission_settings/patcher.rb |
permission_settings-1.0.0 | lib/permission_settings/patcher.rb |