class Camunda::Her::Middleware::SnakeCase
Responsible for handling deserialization of variables.
Public Instance Methods
on_complete(env)
click to toggle source
Check if variables are an Array or JSON and ensure variable names are transformed back from camelCase to snake_case. @param env [Array,Hash]
# File lib/camunda.rb, line 27 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
Private Instance Methods
transform_hash!(hash)
click to toggle source
Return a new hash with all keys converted by the block operation.
# File lib/camunda.rb, line 43 def transform_hash!(hash) hash.deep_transform_keys!(&:underscore) end