Commit 991c68a4e4fc3020afe9b2b259cb3b136ef9c371

Authored by Rodrigo Souto
1 parent 9efdcbd7

api: avoid exception treatment case for every presentation

Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
lib/noosfero/api/entity.rb
... ... @@ -6,9 +6,7 @@ class Noosfero::API::Entity < Grape::Entity
6 6 end
7 7  
8 8 def self.represent(objects, options = {})
9   - if options[:is_inner_data]
10   - super objects, options
11   - else
  9 + if options[:has_exception]
12 10 data = super objects, options.merge(is_inner_data: true)
13 11 if objects.is_a? Exception
14 12 data.merge ok: false, error: {
... ... @@ -18,6 +16,8 @@ class Noosfero::API::Entity < Grape::Entity
18 16 else
19 17 data.merge ok: true, error: { type: 'Success', message: '' }
20 18 end
  19 + else
  20 + super objects, options
21 21 end
22 22 end
23 23  
... ...