class Salesforce::Metadata::Profile
A Salesforce
Profile
metadata object.
See developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_profile.htm
@author Ben Burwell
Attributes
Public Class Methods
Read a profile file from its name and directory
The default file path is `./src/profiles/NAME.profile`, but the directory can be overridden by passing a non-nil String.
@param name [String] the name of the profile to read, like 'Admin' @param dir [String] the directory to search for the profile in. If
nil, defaults to `./src/profiles`.
@return [Profile] the profile object that has been instantiated
# File lib/mdata/metadata/Profile.rb, line 75 def self.read name, dir dir = './src/profiles' if dir.nil? filename = "#{dir}/#{name}.profile" profile = Profile.from_xml(File.read(filename)) profile.filename = filename profile end
Create an empty profile by name in directory
@param name [String] the name of the profile to create @param dir [String] the directory to create it in, defaulting to
`./src/profiles`.
# File lib/mdata/metadata/Profile.rb, line 100 def self.touch name, dir dir = './src/profiles' if dir.nil? filename = "#{dir}/#{name}.profile" profile = Profile.new profile.filename = filename profile.save end
Public Instance Methods
Save the profile to disk, writing it to the file from whence it came
Relies on the profile object having a `@filename` to save to.
# File lib/mdata/metadata/Profile.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