diff options
author | Brenton Leanhardt <bleanhar@redhat.com> | 2008-07-11 14:27:05 -0400 |
---|---|---|
committer | Brenton Leanhardt <bleanhar@redhat.com> | 2008-07-11 15:02:18 -0400 |
commit | 3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3 (patch) | |
tree | 6b44eca9eeae273c0d1c0ba82f9f537cf150ffa0 /genome-bootstrap/lib/genome-bootstrap | |
parent | 53de95c9cb0d5c48341bb9c6124f4d640cd000d5 (diff) | |
download | tools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.tar.gz tools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.tar.xz tools-3ea7ffe3d42dc9d7b1a74f242670db06cf7782c3.zip |
Minor bug fix for genome-bootstrap discovered by the django-example
The django-example only has one class. A String was getting returned where an
Array was assumed. Yay for no unit tests for this.
On a side note, the django-example was useful for uncovering a few corner cases
with how we use Restr. The problem with Restr happens whenever 1 of something
was returned. While it's nice enough wrap things in an Array if multiple items
are returned, since Restr's XmlSimple instance is not setting 'forcearray =>
true' we have to wrap the call.
It would probably be a good idea to ask the Restr maintainer about the
'forcearray' parameter.
Diffstat (limited to 'genome-bootstrap/lib/genome-bootstrap')
-rw-r--r-- | genome-bootstrap/lib/genome-bootstrap/core.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/genome-bootstrap/lib/genome-bootstrap/core.rb b/genome-bootstrap/lib/genome-bootstrap/core.rb index 28b7e61..8991753 100644 --- a/genome-bootstrap/lib/genome-bootstrap/core.rb +++ b/genome-bootstrap/lib/genome-bootstrap/core.rb @@ -136,17 +136,18 @@ module GenomeBootstrap return status.nil? ? nil : status[0] end - # This is a workaround for a Restr "feature". If only one element it is - # returned as a Hash instead of an Array. The way we use Restr assumes that it - # will always return an Array. + # This is a workaround for a Restr "feature". Restr does not set + # 'forcearray => true' for it's XmlSimple instance. This means exactly + # what you would think. We always want to work with arrays since puppet's + # external nodes cares what data structures are used. def restr_get(url, xml_node=nil) data = xml_node ? Restr.get(url)[xml_node] : Restr.get(url) return case data - when Hash - Array.new << data - when Array + when nil, Array data + else + Array.new << data end end end |