Class: Salesforce::Metadata::PermissionSet
- Inherits:
-
Object
- Object
- Salesforce::Metadata::PermissionSet
- Includes:
- ROXML
- Defined in:
- lib/mdata/metadata/PermissionSet.rb
Overview
A Salesforce PermissionSet metadata object.
See developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_permissionset.htm
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
Class Method Summary collapse
-
.read(name, dir) ⇒ PermissionSet
Read a permissionset file from its name and directory.
-
.touch(name, dir) ⇒ Object
Create an empty permissionset by name in directory.
Instance Method Summary collapse
-
#save ⇒ Object
Save the permissionset to disk, writing it to the file from whence it came.
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
15 16 17 |
# File 'lib/mdata/metadata/PermissionSet.rb', line 15 def filename @filename end |
Class Method Details
.read(name, dir) ⇒ PermissionSet
Read a permissionset file from its name and directory
The default file path is ‘./src/permissionsets/NAME.permissionset`, but the directory can be overridden by passing a non-nil String.
75 76 77 78 79 80 81 |
# File 'lib/mdata/metadata/PermissionSet.rb', line 75 def self.read name, dir dir = './src/permissionsets' if dir.nil? filename = "#{dir}/#{name}.permissionset" = PermissionSet.from_xml(File.read(filename)) .filename = filename end |
.touch(name, dir) ⇒ Object
Create an empty permissionset by name in directory
100 101 102 103 104 105 106 |
# File 'lib/mdata/metadata/PermissionSet.rb', line 100 def self.touch name, dir dir = './src/permissionsets' if dir.nil? filename = "#{dir}/#{name}.permissionset" = PermissionSet.new .filename = filename .save end |
Instance Method Details
#save ⇒ Object
Save the permissionset to disk, writing it to the file from whence it came
Relies on the permissionset object having a ‘@filename` to save to.
86 87 88 89 90 91 92 93 |
# File 'lib/mdata/metadata/PermissionSet.rb', line 86 def save doc = ::Nokogiri::XML::Document.new doc.root = to_xml() doc.root.add_namespace nil, 'http://soap.sforce.com/2006/04/metadata' File.open @filename, 'w' do |file| file << doc.to_xml(:indent => 4, :encoding => 'UTF-8') end end |