Method: TLAW::DSL#post_process_replace

Defined in:
lib/tlaw/dsl.rb

#post_process_replace(&block) ⇒ Object

Just like #post_process for entire response, but replaces it with what block returns.

Real-life usage: WorldBank API typically returns responses this way:

[
   {"count": 100, "page": 1},
   {"some_data_variable": [{}, {}, {}]}
]

...e.g. metadata and real response as two items in array, not two keys in hash. We can easily fix this:

post_process_replace do |response|
  {meta: response.first, data: response.last}
end

See also #post_process for some generic explanation of post-processing.



# File 'lib/tlaw/dsl.rb', line 379