From 67decdfc6a6a1e98a3230dc4c8470418273fa475 Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Tue, 19 Nov 2013 01:19:21 -0500 Subject: [PATCH] Cast ActiveRecord::Relation into an Array --- lib/travis/api/app/responders/xml.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index f5ae39ae..5c28671f 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -32,13 +32,13 @@ module Travis::Api::App::Responders } def apply? - super && (single_repo?(resource) || repo_collection?(resource)) + @resource = Array(resource) + super && @resource.first.is_a?(Repository) end def apply super - @resource = resource.is_a?(Repository) ? [resource] : resource TEMPLATE_ERB.result(binding) end @@ -47,13 +47,5 @@ module Travis::Api::App::Responders def content_type 'application/xml;charset=utf-8' end - - def single_repo?(resource) - resource.is_a?(Repository) && resource.last_build - end - - def repo_collection?(resource) - resource.is_a?(ActiveRecord::Relation) && resource.first.is_a?(Repository) - end end end