Class: Salesforce::Types::FieldLevelSecurity

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/mdata/types/FieldLevelSecurity.rb

Overview

A generic FieldLevelSecurity class that can be extended for specific metadata objects, e.g. ProfileFieldLevelSecurity.

Author:

  • Ben Burwell

Direct Known Subclasses

ProfileFieldLevelSecurity

Instance Method Summary collapse

Instance Method Details

#get_permissionsArray

Get all the permissions granted as an easy-to-use Array

Returns:

  • (Array)

    an array of strings representing the permissions that are granted.

Author:

  • Ben Burwell



22
23
24
25
26
27
28
# File 'lib/mdata/types/FieldLevelSecurity.rb', line 22

def get_permissions
	permissions = Array.new
	permissions.push 'Editable' if @editable == 'true'
	permissions.push 'Hidden' if @hidden == 'true'
	permissions.push 'Readable' if @readable == 'true'
	permissions
end

#to_flag_styleString

Produces a string representation of the permissions suitable for displaying in a list, à la ‘ls -la`. The resulting list might look something like this:

Readable Editable
                  Hidden
Readable

Returns:

  • (String)

    the permissions granted on the field, flag-style

Author:

  • Ben Burwell



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mdata/types/FieldLevelSecurity.rb', line 48

def to_flag_style
	flags = ''
	if @readable == 'true'
		flags += 'Readable '
	else
		flags += '         '
	end

	if @editable == 'true'
		flags += 'Editable '
	else
		flags += '         '
	end

	if @hidden == 'true'
		flags += 'Hidden'
	else
		flags += '      '
	end

	flags
end

#to_sString

Get a string representation of the permissions

Returns:

  • (String)

    the permissions granted on the field, comma separated

Author:

  • Ben Burwell



34
35
36
# File 'lib/mdata/types/FieldLevelSecurity.rb', line 34

def to_s
	get_permissions.join(', ')
end