Module: IAmICan::Permission::Helpers::Cls
- Included in:
- Definition
- Defined in:
- lib/i_am_i_can/permission/helpers.rb
Instance Method Summary collapse
- #_pms_definition_result(preds, obj, failed_items) ⇒ Object
- #_to_store_permission(pred, obj, **options) ⇒ Object
- #deconstruct_obj(obj) ⇒ Object
- #defined_local_permissions ⇒ Object
- #defined_permissions ⇒ Object
- #defined_stored_permissions ⇒ Object
- #defined_stored_pms_names ⇒ Object
- #pms_naming(pred, obj) ⇒ Object
- #pms_of_defined_local_role(role_name) ⇒ Object
Instance Method Details
#_pms_definition_result(preds, obj, failed_items) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 5 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 i_am_i_can.strict_mode && fail_msg puts fail_msg || prefix unless ENV['ITEST'] prefix.present? end |
#_to_store_permission(pred, obj, **options) ⇒ Object
13 14 15 16 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 13 def (pred, obj, **) return false if i_am_i_can..exists?(pred, obj) i_am_i_can..create!(pred: pred, **deconstruct_obj(obj), **) end |
#deconstruct_obj(obj) ⇒ Object
22 23 24 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 22 def deconstruct_obj(obj) i_am_i_can..deconstruct_obj(obj) end |
#defined_local_permissions ⇒ Object
26 27 28 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 26 def ||= { } end |
#defined_permissions ⇒ Object
38 39 40 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 38 def .deep_merge() end |
#defined_stored_permissions ⇒ Object
34 35 36 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 34 def i_am_i_can..all.map { |pms| [ pms.name, pms.desc ] }.to_h end |
#defined_stored_pms_names ⇒ Object
30 31 32 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 30 def defined_stored_pms_names i_am_i_can..all.map(&:name) end |
#pms_naming(pred, obj) ⇒ Object
18 19 20 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 18 def pms_naming(pred, obj) i_am_i_can..naming(pred, obj) end |
#pms_of_defined_local_role(role_name) ⇒ Object
42 43 44 |
# File 'lib/i_am_i_can/permission/helpers.rb', line 42 def pms_of_defined_local_role(role_name) i_am_i_can.subject_model.defined_local_roles[role_name.to_sym]&.[](:permissions) || [] end |