Class: Camunda::Middleware::SnakeCase

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/camunda.rb

Overview

Responsible for handling deserialization of variables.

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object

Check if variables are an Array or JSON and ensure variable names are transformed back from camelCase to snake_case.

Parameters:

  • env (Array, Hash)


73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/camunda.rb', line 73

def on_complete(env)
  return if env[:body].blank?

  json = JSON.parse(env[:body])
  case json
  when Array
    json.map { |hash| transform_hash!(hash) }
  when Hash
    transform_hash!(json)
  end
  env[:body] = JSON.generate(json)
end