class PolicyMachineStorageAdapter::Template

Public Instance Methods

add_association(user_attribute, operation_set, object_attribute, policy_machine_uuid) click to toggle source

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.

# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source

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

# 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 = {}) click to toggle source
# 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) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 74
def assign(src, dst)

end
associations_with(operation) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 144
def associations_with(operation)

end
connected?(src, dst) click to toggle source

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

# File lib/policy_machine_storage_adapters/template.rb, line 85
def connected?(src, dst)

end
delete(element) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 106
def delete(element)

end
element_in_machine?(pe) click to toggle source

Determine if the given node is in the policy machine or not. Returns true or false accordingly.

# File lib/policy_machine_storage_adapters/template.rb, line 123
def element_in_machine?(pe)

end
find_all_of_type_object(options = {}) click to toggle source
# File lib/policy_machine_storage_adapters/template.rb, line 55
def find_all_of_type_object(options = {})

end
find_all_of_type_object_attribute(options = {}) click to toggle source
# File lib/policy_machine_storage_adapters/template.rb, line 58
def find_all_of_type_object_attribute(options = {})

end
find_all_of_type_operation(options = {}) click to toggle source
# File lib/policy_machine_storage_adapters/template.rb, line 61
def find_all_of_type_operation(options = {})

end
find_all_of_type_policy_class(options = {}) click to toggle source
# File lib/policy_machine_storage_adapters/template.rb, line 64
def find_all_of_type_policy_class(options = {})

end
find_all_of_type_user(options = {}) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 49
def find_all_of_type_user(options = {})

end
find_all_of_type_user_attribute(options = {}) click to toggle source
# File lib/policy_machine_storage_adapters/template.rb, line 52
def find_all_of_type_user_attribute(options = {})

end
policy_classes_for_object_attribute(object_attribute) click to toggle source

Return array of all policy classes which contain the given object_attribute (or object). Return empty array if no such policy classes found.

# 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) click to toggle source
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

# File lib/policy_machine_storage_adapters/template.rb, line 172
def scoped_privileges(user_or_attribute, object_or_attribute)

end
transaction() click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 165
def transaction

end
unassign(src, dst) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 97
def unassign(src, dst)

end
update(element, changes_hash) click to toggle source

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.

# File lib/policy_machine_storage_adapters/template.rb, line 115
def update(element, changes_hash)

end
user_attributes_for_user(user) click to toggle source

Return array of all user attributes which contain the given user. Return empty array if no such user attributes are found.

# File lib/policy_machine_storage_adapters/template.rb, line 158
def user_attributes_for_user(user)
end