Class: ScoutApm::Config::JsonCoercion

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/config.rb

Overview

If the passed value is a string, attempt to decode as json This is a no-op unless the ‘JSON` constant is defined

Instance Method Summary collapse

Instance Method Details

#coerce(val) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/scout_apm/config.rb', line 127

def coerce(val)
  case val
  when String
    if defined?(JSON) && JSON.respond_to?(:parse)
      JSON.parse(val)
    else
      val
    end
  else
    val
  end
end