class MyHash < Hash
  def method_missing(method, *args, &block)
    puts "method_missing   method  = #{method}"
    return store_attribute(method, *args) if method.end_with?('=')
    return self[method] if self.has_key?(method)
    super
  end
  def respond_to_missing?(method,include_private = false)
    self.has_key?(method) || method.end_with?('=') || super
  end

  private
  def store_attribute(method, *args)
    key=method.to_s.delete_suffix('=')
    self[key.to_sym] = args[0]
    p "для экземпляра класса =#{self.class}  создаем хеш  с key=#{key} значение = #{args[0]}"
  end

end

s = MyHash.new
s.mytestmethod = "test data for me"
puts s.mytestmethod
s.mytest = 100
puts s.mytest
puts s.inspect
puts s.respond_to?(:mytest)
puts s.respond_to?(:mytest=)