lib/hermod/xml_section_builder.rb
# Public: defines a node for sending a monetary value to HMRC
#
# name    - the name of the node. This will become the name of the method on the XmlSection.
# options - a hash of options used to set up validations.
#
# Returns nothing you should rely on
defines a node for sending a monetary value to HMRC
name    - the name of the node. This will become the name of the method on the XmlSection.
options - a hash of options used to set up validations.

Returns nothing you should rely on
defines a node for sending a monetary value to HMRC name - the name of the node . This will become the name of the method on the XmlSection . options - a hash of options used to set up validations . Returns nothing you should rely on
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
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
Public: defines a node for sending a monetary value to HMRC
name    - the name of the node.
Public : defines a node for sending a monetary value to HMRC name - the name of the node .
name
options