Module: Datadog::AppSec::Utils::HashCoercion
- Defined in:
- lib/datadog/appsec/utils/hash_coercion.rb
Overview
A module for coercing arbitrary objects into hashes.
Class Method Summary collapse
-
.coerce(object) ⇒ Hash?
A best effort to coerce an object to a hash with methods known to various frameworks with a fallback to standard library.
Class Method Details
.coerce(object) ⇒ Hash?
A best effort to coerce an object to a hash with methods known to various frameworks with a fallback to standard library.
13 14 15 16 17 18 19 |
# File 'lib/datadog/appsec/utils/hash_coercion.rb', line 13 def self.coerce(object) return object.as_json if object.respond_to?(:as_json) return object.to_hash if object.respond_to?(:to_hash) return object.to_h if object.respond_to?(:to_h) nil end |