Sha256: b77aa9a8d8cb2150e5934b80d80833058a77fb1c9f43956bc92b774a7783b2d2
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module IAmICan module Permission module Helpers module Cls def _pms_definition_result(preds, obj, failed_items) prefix = 'Permission Definition Done' fail_msg = prefix + ", but #{failed_items} have been defined" if failed_items.present? raise Error, fail_msg if config.strict_mode && fail_msg fail_msg ? fail_msg : prefix end def _to_store_permission(pred, obj, **options) return false if config.permission_model.exists?(pred, obj) config.permission_model.create!(pred: pred, **deconstruct_obj(obj), **options) end def pms_naming(pred, obj) config.permission_model.naming(pred, obj) end def deconstruct_obj(obj) config.permission_model.deconstruct_obj(obj) end def pms_of_defined_local_role(role_name) config.subject_model.defined_local_roles[role_name.to_sym]&.[](:permissions) || [] end end module Ins def _pms_assignment_result(preds, obj, not_defined_items, covered_items = nil, strict_mode = false) prefix = 'Permission Assignment Done' msg1 = "#{not_defined_items} have not been defined" if not_defined_items.present? msg2 = "#{covered_items} have been covered" if covered_items.present? fail_msg = prefix + ', but ' + [msg1, msg2].compact.join(', ') if msg1 || msg2 raise Error, fail_msg if (strict_mode || config.strict_mode) && fail_msg fail_msg ? fail_msg : prefix end def pms_matched?(pms_name, plist) config.permission_model.matched?(pms_name, in: plist[:in]) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i_am_i_can-2.1.0 | lib/i_am_i_can/permission/helpers.rb |