Method: Hermod::XmlSectionBuilder#string_node
- Defined in:
- lib/hermod/xml_section_builder.rb
#string_node(name, options = {}) ⇒ Object
Public: defines a node for sending a string 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hermod/xml_section_builder.rb', line 66 def string_node(name, ={}) mutators = [].tap do |mutators| mutators << InputMutator.new(.delete(:input_mutator)) if .has_key? :input_mutator end validators = [].tap do |validators| validators << Validators::AllowedValues.new(.delete(:allowed_values)) if .has_key? :allowed_values validators << Validators::RegularExpression.new(.delete(:matches)) if .has_key? :matches validators << Validators::ValuePresence.new unless .delete(:optional) validators << Validators::Attributes.new(.fetch(:attributes, {}).keys) end create_method(name, mutators, validators, ) do |value, attributes| [value, attributes] end end |