The reason you are getting this warning is that the construct: $foo->{bar}, with the arrow and the brackets, only work are things that are either hash referenecs or blessed hash references. In this case, $self is a blessed scalar, so you can't treat it as a hash reference.
If you want to fix it, go to line 6, bless \$name, $class;
And change it so that you are blessing a hash reference.