def instantiate_models(model_class, source)
      return nil if source.nil?

      source = prepare_source model_class, source

      if source.is_a? Array
        source.map { |entry| instantiate_models model_class, entry }
      elsif source.is_a? Hash
        instantiate_model_from_attributes_hash model_class, source
      else
        raise ArgumentError, "#{model_class}: can't instantiate from a source of type #{source.class}"
      end
    end
def instantiate_models(model_class, source)
      return nil if source.nil?

      source = prepare_source model_class, source

      if source.is_a? Array
        source.map { |entry| instantiate_models model_class, entry }
      elsif source.is_a? Hash
        instantiate_model_from_attributes_hash model_class, source
      else
        raise ArgumentError, "#{model_class}: can't instantiate from a source of type #{source.class}"
      end
    end
This method is used to instantiate the various `Model` subclasses from data returned by the IG Markets API. It
 recurses through arrays and sub-hashes present in `source`, instantiating the required models based on the types
 of each attribute as defined on the models. All model instances returned by this method will have their
 `@dealing_platform` instance variable set.

 @param [Class] model_class The top-level model class to create from `source`.
 @param [nil, Hash, Array, Model] source The source object to construct the model(s) from. If `nil` then `nil` is
                                  returned. If an instance of `model_class` subclass then a deep copy of it is
                                  returned. If a `Hash` then it will be interpreted as the attributes for a new
                                  instance of `model_class. If an `Array` then each entry will be passed through
                                  this method individually.

 @return [nil, `model_class`, Array<`model_class`>] The resulting instantiated model(s).

 @private