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



144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/scout_apm/config.rb', line 144

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