Module: Deimos::Utils::SchemaClass
- Defined in:
- lib/deimos/utils/schema_class.rb
Overview
Class used by SchemaClassGenerator and Consumer/Producer interfaces
Class Method Summary collapse
-
.instance(payload, schema) ⇒ Deimos::SchemaClass::Record
Converts a raw payload into an instance of the Schema Class.
- .use?(config) ⇒ Boolean
Class Method Details
.instance(payload, schema) ⇒ Deimos::SchemaClass::Record
Converts a raw payload into an instance of the Schema Class
12 13 14 15 16 17 |
# File 'lib/deimos/utils/schema_class.rb', line 12 def instance(payload, schema) klass = "Schemas::#{schema.underscore.camelize}".safe_constantize return payload if klass.nil? || payload.nil? klass.new(**payload.symbolize_keys) end |
.use?(config) ⇒ Boolean
21 22 23 24 |
# File 'lib/deimos/utils/schema_class.rb', line 21 def use?(config) use_schema_classes = config[:use_schema_classes] use_schema_classes.present? ? use_schema_classes : Deimos.config.schema.use_schema_classes end |