Cast ActiveRecord::Relation into an Array
This commit is contained in:
parent
0fe9e6da90
commit
67decdfc6a
|
@ -32,13 +32,13 @@ module Travis::Api::App::Responders
|
||||||
}
|
}
|
||||||
|
|
||||||
def apply?
|
def apply?
|
||||||
super && (single_repo?(resource) || repo_collection?(resource))
|
@resource = Array(resource)
|
||||||
|
super && @resource.first.is_a?(Repository)
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply
|
def apply
|
||||||
super
|
super
|
||||||
|
|
||||||
@resource = resource.is_a?(Repository) ? [resource] : resource
|
|
||||||
TEMPLATE_ERB.result(binding)
|
TEMPLATE_ERB.result(binding)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,13 +47,5 @@ module Travis::Api::App::Responders
|
||||||
def content_type
|
def content_type
|
||||||
'application/xml;charset=utf-8'
|
'application/xml;charset=utf-8'
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user