class Hermod::XmlSectionBuilder
def monetary_node(name, options={})
options - a hash of options used to set up validations.
name - the name of the node. This will become the name of the method on the XmlSection.
Public: defines a node for sending a monetary value to HMRC
def monetary_node(name, options={}) validators = [].tap do |validators| validators << Validators::NonNegative.new unless options.fetch(:negative, true) validators << Validators::NonZero.new unless options.fetch(:zero, true) validators << Validators::WholeUnits.new if options[:whole_units] end create_method(name, [], validators, options) do |value, attributes| value ||= value.to_i if options[:optional] && value == 0 [nil, attributes] else [sprintf(format_for(:money), value), attributes] end end end