def instantiate_model_from_attributes_hash(model_class, attributes)
      model_class.new.tap do |model|
        model.instance_variable_set :@dealing_platform, self

        attributes.each do |attribute, value|
          next unless model.class.valid_attribute? attribute

          type = model.class.attribute_type attribute
          value = instantiate_models type, value if type < Model

          set_model_attribute_value model, attribute, value
        end
      end
    end
def instantiate_model_from_attributes_hash(model_class, attributes)
      model_class.new.tap do |model|
        model.instance_variable_set :@dealing_platform, self

        attributes.each do |attribute, value|
          next unless model.class.valid_attribute? attribute

          type = model.class.attribute_type attribute
          value = instantiate_models type, value if type < Model

          set_model_attribute_value model, attribute, value
        end
      end
    end
This method is a companion to {#instantiate_models} and creates a single instance of `model_class` from the passed
 attributes hash, setting the `@dealing_platform` instance variable on the new model instance.