Class: CakeMail::ServiceClass

Inherits:
Object
  • Object
show all
Defined in:
lib/cakemail/service.rb

Defined Under Namespace

Classes: InvalidMethod

Class Method Summary collapse

Class Method Details

.method(args) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
# File 'lib/cakemail/service.rb', line 29

def self.method(args)
  raise ArgumentError.new("args or name missing") if args.nil? or args[:name].nil?
  @methods ||= { }
  name = args[:name]
  @methods[name] = ServiceMethod.new(name, args[:requires] || [ ], args[:optional] || [ ], args[:custom_args_xml] || [ ])
end

.method_xml(builder, session, method, args) ⇒ Object

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
# File 'lib/cakemail/service.rb', line 36

def self.method_xml(builder, session, method, args)
  raise ArgumentError.new("builder or session missing") if builder.nil? or session.nil?
  raise InvalidMethod unless @methods.has_key?(method)
  builder.class(:type => self.to_s.gsub(/.*::/, ''), :locale => session.class::API_LOCALE) do |klass|
    klass.method(:type => method) do |meth|
      @methods[method].to_xml(meth, args)
    end
  end
end