Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Missing stuff

  • Loading branch information...
commit 7c9a5351e8370ed95fc2e988e91eced7a016e500 1 parent bd100bf
@mpermar mpermar authored
View
12 src/groovy/com/tropo/grails/TropoBuilder.groovy
@@ -282,6 +282,11 @@ class TropoBuilder extends BuilderSupport {
value = cleanGStrings(value)
if (name == "say") {
+ if (value instanceof Object[]) {
+ def list = new ArrayList()
+ value.each { list << it }
+ value = list
+ }
if (!(value instanceof String) && !(value instanceof Map) && !(value instanceof List)) {
throw new TropoBuilderException("An invalid paramater type ${value.getClass()} has been passed")
}
@@ -345,7 +350,12 @@ class TropoBuilder extends BuilderSupport {
if (!root) {
reset()
- }
+ }/*
+ if (arg0.equals("say") && arg2 instanceof Object[] && arg2.length > 1) {
+ def list = new ArrayList()
+ list << arg2
+ arg2 = list
+ }*/
return super.doInvokeMethod(arg0, arg1, arg2);
}
View
12 test/unit/com/tropo/grails/TropoBuilderTests.groovy
@@ -321,7 +321,17 @@ class TropoBuilderTests extends GroovyTestCase {
assert builder.text() == """{"tropo":[{"say":[{"value":"1234"},{"value":"abcd","event":"nomatch:1"}]}]}"""
}
-
+
+ public void testSayWithArrayArgument2() {
+
+ def builder = new TropoBuilder()
+ builder.tropo {
+ say([[value: '1234'], [value: 'abcd', event: 'nomatch:1'],[value: '1234', event: 'timeout:1'],[value: '1234', event: 'timeout:2']])
+ }
+ println builder.text()
+ assert builder.text() == """{"tropo":[{"say":[{"value":"1234"},{"value":"abcd","event":"nomatch:1"},{"value":"1234","event":"timeout:1"},{"value":"1234","event":"timeout:2"}]}]}"""
+ }
+
public void testSayWithMoreThanTwoArrayArguments() {
def builder = new TropoBuilder()
Please sign in to comment.
Something went wrong with that request. Please try again.