def aggregate(function, format = {:format => nil})
DDL.validation_fail!(:PLMC28, "Formats supplied to aggregation functions should be a hash", :error) unless format.is_a?(Hash)
DDL.validation_fail!(:PLMC27, "Formats supplied to aggregation functions must have a :format key", :error) unless format.keys.include?(:format)
DDL.validation_fail!(:PLMC26, "Functions supplied to aggregate should be a hash", :error) unless function.is_a?(Hash)
unless (function.keys.include?(:args)) && function[:args]
DDL.validation_fail!(:PLMC25, "aggregate method for action '%{action}' missing a function parameter", :error, :action => entities[@current_entity][:action])
end
entities[@current_entity][:aggregate] ||= []
entities[@current_entity][:aggregate] << (format[:format].nil? ? function : function.merge(format))
end