class Artifactory::Resource::PermissionTarget::Principal
def abbreviate_permissions(array)
Replace an array of verbose permission names with an equivalent array of abbreviated permission names.
def abbreviate_permissions(array) inverse = VERBOSE_PERMS.invert if (inverse.keys & array).sort != array.sort then raise "One of your principals contains an invalid permission. Valid permissions are #{inverse.keys.join(', ')}" end array.map { |elt| inverse[elt] }.sort end
def abbreviate_principal(principal_hash)
Replace a principal with verbose permissions with an equivalent one with abbreviated permissions.
def abbreviate_principal(principal_hash) Hash[principal_hash.map { |k, v| [k, abbreviate_permissions(v)] } ] end
def initialize(users = {}, groups = {})
def initialize(users = {}, groups = {}) @users = users @groups = groups end
def to_abbreviated
-
(Hash)
-
def to_abbreviated { 'users' => abbreviate_principal(@users), 'groups' => abbreviate_principal(@groups) } end