Class: Metaforce::Metadata::MetadataFile
- Inherits:
-
Hash
- Object
- Hash
- Metaforce::Metadata::MetadataFile
- Defined in:
- lib/metaforce/metadata/file.rb
Class Method Summary collapse
-
.template(type) ⇒ Object
Builds a new MetadataFile object based on the template.
Instance Method Summary collapse
-
#initialize(hash, type) ⇒ MetadataFile
constructor
Initialize the underlying hash.
-
#to_xml ⇒ Object
Returns the xml representation of the underlying hash structure.
- #type ⇒ Object
Constructor Details
#initialize(hash, type) ⇒ MetadataFile
Initialize the underlying hash
8 9 10 11 12 |
# File 'lib/metaforce/metadata/file.rb', line 8 def initialize(hash, type) super(hash) @type = type replace(hash) end |
Class Method Details
.template(type) ⇒ Object
Builds a new MetadataFile object based on the template
Examples
Metaforce::Metadata::MetadataFile.template(:apex_class)
#=> {:api_version=>"23.0", :status=>"Active"}
24 25 26 |
# File 'lib/metaforce/metadata/file.rb', line 24 def self.template(type) Metaforce::Metadata::MetadataFile.new(TEMPLATES[type], type) end |
Instance Method Details
#to_xml ⇒ Object
Returns the xml representation of the underlying hash structure
Examples
f = Metaforce::Metadata::MetadataFile.template(:apex_class)
f.to_xml
#=> "<?xml version=\"1.0\"?>\n<ApexClass xmlns=\"http://soap.sforce.com/2006/04/metadata\">\n <apiVersion>23.0</apiVersion>\n <status>Active</status>\n</ApexClass>\n"
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/metaforce/metadata/file.rb', line 35 def to_xml xml_builder = Nokogiri::XML::Builder.new do |xml| xml.send(type.to_s.camelcase, "xmlns" => "http://soap.sforce.com/2006/04/metadata") do self.each do |key, value| xml.send(key.to_s.lower_camelcase, value) end end end xml_builder.to_xml end |
#type ⇒ Object
14 15 16 |
# File 'lib/metaforce/metadata/file.rb', line 14 def type @type end |