class IntacctRuby::Functions::BaseFunction

Creates the basic structure for all functions. Meant to be an interface: this should not be implemented on its own.

Public Class Methods

new(controlid, attrs = {}) click to toggle source
# File lib/intacct_ruby/functions/base_function.rb, line 8
def initialize(controlid, attrs = {})
  @controlid = controlid
  @attrs = attrs

  @xml = Builder::XmlMarkup.new
end

Public Instance Methods

to_xml() { |xml| ... } click to toggle source
# File lib/intacct_ruby/functions/base_function.rb, line 15
def to_xml
  @to_xml ||= begin
    @xml.function controlid: @controlid do
      yield(@xml)
    end

    # converts xml to string
    @xml.target!
  end
end

Private Instance Methods

custom_field_params(custom_fields) click to toggle source
# File lib/intacct_ruby/functions/base_function.rb, line 32
def custom_field_params(custom_fields)
  xml = Builder::XmlMarkup.new

  xml.customfields do
    custom_fields.each do |name, value|
      xml.customfield do
        xml.customfieldname   name.to_s
        xml.customfieldvalue  value.to_s
      end
    end
  end

  xml.target!
end
timestamp() click to toggle source
# File lib/intacct_ruby/functions/base_function.rb, line 28
def timestamp
  @timestamp ||= Time.now.utc.to_s
end