Class: CakeMail::ServiceMethod

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, requires, optional, custom_args_xml) ⇒ ServiceMethod

Returns a new instance of ServiceMethod.



5
6
7
8
9
10
# File 'lib/cakemail/service.rb', line 5

def initialize(name, requires, optional, custom_args_xml)
  @name = name
  @requires = requires
  @optional = optional
  @custom_args_xml = custom_args_xml
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/cakemail/service.rb', line 3

def name
  @name
end

#optionalObject (readonly)

Returns the value of attribute optional.



3
4
5
# File 'lib/cakemail/service.rb', line 3

def optional
  @optional
end

#requiresObject (readonly)

Returns the value of attribute requires.



3
4
5
# File 'lib/cakemail/service.rb', line 3

def requires
  @requires
end

Instance Method Details

#to_xml(builder, args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cakemail/service.rb', line 12

def to_xml(builder, args)
  @requires.each do |arg|
    raise ArgumentError.new(arg.to_s) unless args.has_key?(arg)
    builder.__send__(arg.to_s, args[arg])
  end
  @optional.each do |arg|
    builder.__send__(arg.to_s, args[arg]) if args.has_key?(arg)
  end
  @custom_args_xml.each do |arg|
    arg.call(builder, args)
  end
end