Cast ActiveRecord::Relation into an Array

This commit is contained in:
Hiro Asari 2013-11-19 01:19:21 -05:00
parent 0fe9e6da90
commit 67decdfc6a

View File

@ -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