Method: Hermod::XmlSectionBuilder#integer_node

Defined in:
lib/hermod/xml_section_builder.rb

#integer_node(name, options = {}) ⇒ Object

Public: defines a node for sending an integer 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



87
88
89
90
91
92
93
94
95
96
# File 'lib/hermod/xml_section_builder.rb', line 87

def integer_node(name, options={})
  validators = [].tap do |validators|
    if options.has_key? :range
      validators << Validators::Range.new(options[:range][:min], options[:range][:max])
    end
  end
  create_method(name, [], validators, options) do |value, attributes|
    [value.to_s, attributes]
  end
end