Ad
  • Custom User Avatar

    Hello everyone,

    It would be great to get some feedback on this Error Message.

    Make sure dynamic attributes don't persist across different instances of GenericEntity objects.

    I do not understand what they mean by this. Because when I create different object they do are present because I put all the code running at initialization.

    My code so far is:

    class GenericEntity
      def initialize(hash)
        define_instance_variables_and_reader(hash)
      end
    
      def define_instance_variables_and_reader(hash)
        hash.each do |k, v|
          instance_variable_set("@#{k}", v)
          self.class.send(:attr_reader, k)
        end
      end
    end
    

    Additionally do you have any ressources to read about this topic and realted to Ruby?

    Many thanks

    Faouzi

  • Default User Avatar

    After submitted I got such error message:

    dog's instance variable @barks isn't what it was set to in the hash - Expected: "obnoxiously", instead got: nil
    

    But I have tried to test all the tests in my local machine, I got the expected results instead of nil.