class MML::Base

Public Class Methods

mandatory_attribute(*attrs) click to toggle source
# File lib/mml.rb, line 21
def mandatory_attribute(*attrs)
  attrs.each do |attr|
    class_eval %{
      attr_reader attr
      
      def #{attr}=(value)
        raise ArgumentError, '#{attr} is mandatory' if value.nil?
        @#{attr}=value
      end
    }
  end
end
new(args = {}) click to toggle source
# File lib/mml.rb, line 8
def initialize(args = {})
  args.keys.each do |item|
    send "#{item.to_s}=", args[item]
  end
end

Public Instance Methods

namespace() click to toggle source
# File lib/mml.rb, line 14
def namespace
  MML_NAMESPACE
end
to_xml() click to toggle source
# File lib/mml.rb, line 35
def to_xml
  xml = Builder::XmlMarkup.new
  eval xml_builder
end

Private Instance Methods

builder_file_prefix() click to toggle source
# File lib/mml.rb, line 49
def builder_file_prefix
  self.class.to_s.split('::').last.downcase
end
this_file_path() click to toggle source
# File lib/mml.rb, line 53
def this_file_path
  File.expand_path(File.dirname(__FILE__))
end
xml_builder() click to toggle source
# File lib/mml.rb, line 41
def xml_builder
  File.read(xml_builder_file)
end
xml_builder_file() click to toggle source
# File lib/mml.rb, line 45
def xml_builder_file
  File.join(this_file_path, 'xml', "#{builder_file_prefix}.xml.builder")
end