Class: PolicyMachineStorageAdapter::Template
- Inherits:
-
Object
- Object
- PolicyMachineStorageAdapter::Template
- Defined in:
- lib/policy_machine_storage_adapters/template.rb
Instance Method Summary collapse
-
#add_association(user_attribute, operation_set, object_attribute, policy_machine_uuid) ⇒ Object
Add the given association to the policy map.
- #add_object(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
- #add_object_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
- #add_operation(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
- #add_policy_class(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
-
#add_user(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
The following add_* methods store a policy element in the policy machine.
- #add_user_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
-
#assign(src, dst) ⇒ Object
Assign src to dst in policy machine.
-
#associations_with(operation) ⇒ Object
Return an array of all associations in which the given operation is included.
-
#connected?(src, dst) ⇒ Boolean
Determine if there is a path from src to dst in the policy machine.
-
#delete(element) ⇒ Object
Remove a persisted policy element.
-
#element_in_machine?(pe) ⇒ Boolean
Determine if the given node is in the policy machine or not.
- #find_all_of_type_object(options = {}) ⇒ Object
- #find_all_of_type_object_attribute(options = {}) ⇒ Object
- #find_all_of_type_operation(options = {}) ⇒ Object
- #find_all_of_type_policy_class(options = {}) ⇒ Object
-
#find_all_of_type_user(options = {}) ⇒ Object
The following find_* methods should return an array of persisted policy elements of the given type (e.g. user or object_attribute) and extra attributes.
- #find_all_of_type_user_attribute(options = {}) ⇒ Object
-
#policy_classes_for_object_attribute(object_attribute) ⇒ Object
Return array of all policy classes which contain the given object_attribute (or object).
-
#scoped_privileges(user_or_attribute, object_or_attribute) ⇒ Object
Optimized version of PolicyMachine#scoped_privileges Return all operations the user has on the object Optional: only add this method if you can do it better than policy_machine.rb.
-
#transaction ⇒ Object
Execute the passed-in block transactionally: any error raised out of the block causes all the block’s changes to be rolled back.
-
#unassign(src, dst) ⇒ Object
Disconnect two policy elements in the machine The two policy elements must be persisted policy elements; otherwise the method should raise an ArgumentError.
-
#update(element, changes_hash) ⇒ Object
Update the extra_attributes of a persisted policy element.
-
#user_attributes_for_user(user) ⇒ Object
Return array of all user attributes which contain the given user.
Instance Method Details
#add_association(user_attribute, operation_set, object_attribute, policy_machine_uuid) ⇒ Object
Add the given association to the policy map. If an association between user_attribute and object_attribute already exists, then replace it with that given in the arguments. Returns true if the association was added and false otherwise.
132 133 134 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 132 def add_association(user_attribute, operation_set, object_attribute, policy_machine_uuid) end |
#add_object(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
30 31 32 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 30 def add_object(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#add_object_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
33 34 35 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 33 def add_object_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#add_operation(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
36 37 38 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 36 def add_operation(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#add_policy_class(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
39 40 41 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 39 def add_policy_class(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#add_user(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
The following add_* methods store a policy element in the policy machine. The unique_identifier identifies the element within the policy machine. The policy_machine_uuid is the uuid of the containing policy machine. Extra attributes should be persisted as metadata associated with the object. Each method should return the persisted policy element. Persisted policy element objects should respond to each extra attribute key as well as the following methods:
-
unique_identifier
-
policy_machine_uuid
-
persisted
24 25 26 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 24 def add_user(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#add_user_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) ⇒ Object
27 28 29 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 27 def add_user_attribute(unique_identifier, policy_machine_uuid, extra_attributes = {}) end |
#assign(src, dst) ⇒ Object
Assign src to dst in policy machine. The two policy elements must be persisted policy elements; otherwise the method should raise an ArgumentError. Returns true if the assignment occurred, false otherwise.
74 75 76 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 74 def assign(src, dst) end |
#associations_with(operation) ⇒ Object
Return an array of all associations in which the given operation is included. Each element of the array should itself be an array in which the first element is the user_attribute member of the association, the second element is a Ruby Set, each element of which is an operation, the third element is the object_attribute member of the association. If no associations are found then the empty array should be returned.
144 145 146 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 144 def associations_with(operation) end |
#connected?(src, dst) ⇒ Boolean
Determine if there is a path from src to dst in the policy machine. The two policy elements must be persisted policy elements; otherwise the method should raise an ArgumentError. Returns true if there is a such a path and false otherwise. Should return true if src == dst
85 86 87 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 85 def connected?(src, dst) end |
#delete(element) ⇒ Object
Remove a persisted policy element. This should remove its assignments and associations but must not cascade to any connected policy elements. Returns true if the delete succeeded.
106 107 108 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 106 def delete(element) end |
#element_in_machine?(pe) ⇒ Boolean
Determine if the given node is in the policy machine or not. Returns true or false accordingly.
123 124 125 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 123 def element_in_machine?(pe) end |
#find_all_of_type_object(options = {}) ⇒ Object
55 56 57 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 55 def find_all_of_type_object( = {}) end |
#find_all_of_type_object_attribute(options = {}) ⇒ Object
58 59 60 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 58 def find_all_of_type_object_attribute( = {}) end |
#find_all_of_type_operation(options = {}) ⇒ Object
61 62 63 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 61 def find_all_of_type_operation( = {}) end |
#find_all_of_type_policy_class(options = {}) ⇒ Object
64 65 66 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 64 def find_all_of_type_policy_class( = {}) end |
#find_all_of_type_user(options = {}) ⇒ Object
The following find_* methods should return an array of persisted policy elements of the given type (e.g. user or object_attribute) and extra attributes. If no such persisted policy elements are found, the empty array should be returned.
49 50 51 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 49 def find_all_of_type_user( = {}) end |
#find_all_of_type_user_attribute(options = {}) ⇒ Object
52 53 54 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 52 def find_all_of_type_user_attribute( = {}) end |
#policy_classes_for_object_attribute(object_attribute) ⇒ Object
Return array of all policy classes which contain the given object_attribute (or object). Return empty array if no such policy classes found.
151 152 153 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 151 def policy_classes_for_object_attribute(object_attribute) end |
#scoped_privileges(user_or_attribute, object_or_attribute) ⇒ Object
Optimized version of PolicyMachine#scoped_privileges Return all operations the user has on the object Optional: only add this method if you can do it better than policy_machine.rb
172 173 174 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 172 def scoped_privileges(user_or_attribute, object_or_attribute) end |
#transaction ⇒ Object
Execute the passed-in block transactionally: any error raised out of the block causes all the block’s changes to be rolled back. Should raise NotImplementedError if the persistence layer does not support this.
165 166 167 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 165 def transaction end |
#unassign(src, dst) ⇒ Object
Disconnect two policy elements in the machine The two policy elements must be persisted policy elements; otherwise the method should raise an ArgumentError. Returns true if unassignment occurred and false otherwise. Generally, false will be returned if the assignment didn’t exist in the PM in the first place.
97 98 99 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 97 def unassign(src, dst) end |
#update(element, changes_hash) ⇒ Object
Update the extra_attributes of a persisted policy element. This should only affect attributes corresponding to the keys passed in. Returns true if the update succeeded or was redundant.
115 116 117 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 115 def update(element, changes_hash) end |
#user_attributes_for_user(user) ⇒ Object
Return array of all user attributes which contain the given user. Return empty array if no such user attributes are found.
158 159 |
# File 'lib/policy_machine_storage_adapters/template.rb', line 158 def user_attributes_for_user(user) end |